tests/testthat/test-region_exclusion.R

context("test-filters")

test_that("nmr_exclude_region works", {
  dataset <- new_nmr_dataset_1D(ppm_axis = c(1,2,3),
                           data_1r = matrix(c(1,2,1), nrow = 1),
                           metadata = list(external = data.frame(NMRExperiment = "10")))
  regions_to_exclude <- list(water = c(1, 2))
  dataset <- nmr_exclude_region(dataset, exclude = regions_to_exclude)
  expect_equal(dataset[["data_1r"]], 1)
})

test_that("AlpsNMR filter works", {
  dataset <- new_nmr_dataset_1D(ppm_axis = c(1,2,3),
                                data_1r = matrix(c(1,2,1,1,2,1), nrow = 2),
                                metadata = list(external = data.frame(NMRExperiment = c("10", "20"))))
  dataset <- filter(dataset, NMRExperiment == "10")
  expect_equal(dataset[["num_samples"]], 1)
})

test_that("AlpsNMR filter works", {
  dataset <- new_nmr_dataset_1D(ppm_axis = c(1,2,3),
                                data_1r = matrix(c(1,2,1,1,2,1), nrow = 2),
                                metadata = list(external = data.frame(NMRExperiment = c("10", "20"))))
  dataset <- filter(dataset, NMRExperiment == "10")
  meta <- nmr_meta_get(dataset, groups = "external")
  #Force error language to English
  Sys.setenv(LANGUAGE='en')
  expect_error(meta[["NMRExperiment"]][[2]], "subscript out of bounds")
})

Try the AlpsNMR package in your browser

Any scripts or data that you put into this service are public.

AlpsNMR documentation built on April 1, 2021, 6:02 p.m.