tests/testthat/test_gcms.R

library(lab.routines)

d <- read_gcms("ex_gcms_data.csv")
context("Read GC-MS data")
test_that("read_gcms returns a data frame", {
            expect_is(d, "data.frame")
})
test_that("read_gcms reads analytes into data frame column", {
            expect_equal(unique(d$analyte)[1:3],
                         c("quinone", "phenol-d5", "phenol"))
})

test_that("read_gcms produces correct namespace", {
            expect_equal(colnames(d), c("analyte", "name", "data_file", "type",
                                        "acq_datetime", "level", "rt", "rrt",
                                        "area", "fwhm", "s/n", "rr",
                                        "accuracy", "symmetry", "conc"))
})

cal2 <- d[(d$name == "cp-10-1-2" & d$analyte == "quinone"), "conc"]
test_that("read_gcms gathers data correctly", {
            expect_equal(cal2, 10.1485)
})
jdavisagua/lab.routines documentation built on May 4, 2019, 7:37 a.m.