diff --git a/R/read_txt_Renishaw.R b/R/read_txt_Renishaw.R index a565035..56bedb9 100644 --- a/R/read_txt_Renishaw.R +++ b/R/read_txt_Renishaw.R @@ -164,48 +164,47 @@ read_txt_Renishaw <- function(file = stop("file is required"), hySpc.testthat::test(read_txt_Renishaw) <- function() { context("read_txt_Renishaw") + path <- system.file("extdata", "txt.Renishaw", package = "hySpc.read.txt") + f_paracetamol <- paste0(path, "/paracetamol.txt") + f_laser <- paste0(path, "/laser.txt.gz") + f_chondro <- paste0(path, "/chondro.txt") test_that("single spectrum", { - skip("TODO: adapt to new package") - tmp <- read_txt_Renishaw("fileio/txt.Renishaw/paracetamol.txt", "spc") + tmp <- read_txt_Renishaw(f_paracetamol, "spc") expect_equal(dim(tmp), c(nrow = 1L, ncol = 2L, nwl = 4064L)) }) test_that("time series spectrum, gzipped", { - skip("TODO: adapt to new package") - tmp <- read_txt_Renishaw("fileio/txt.Renishaw/laser.txt.gz", "ts") + tmp <- read_txt_Renishaw(f_laser, "ts") expect_equal(dim(tmp), c(nrow = 84L, ncol = 3L, nwl = 140L)) expect_equal(colnames(tmp), c("t", "spc", "filename")) }) test_that("map (= default)", { - skip("TODO: adapt to new package") - tmp <- read_txt_Renishaw("fileio/txt.Renishaw/chondro.txt", "xyspc") + tmp <- read_txt_Renishaw(f_chondro, "xyspc") expect_equal(dim(tmp), c(nrow = 875L, ncol = 4L, nwl = 1272L)) expect_equal(colnames(tmp), c("y", "x", "spc", "filename")) - tmp <- read_txt_Renishaw("fileio/txt.Renishaw/chondro.txt") + tmp <- read_txt_Renishaw(f_chondro) expect_equal(dim(tmp), c(nrow = 875L, ncol = 4L, nwl = 1272L)) expect_equal(colnames(tmp), c("y", "x", "spc", "filename")) }) test_that("chunked reading", { - skip("TODO: adapt to new package") ## error on too small chunk size expect_error( - read_txt_Renishaw("fileio/txt.Renishaw/chondro.txt", nlines = 10), + read_txt_Renishaw(f_chondro, nlines = 10), "Wavelengths do not correspond" ) - tmp <- read_txt_Renishaw("fileio/txt.Renishaw/chondro.txt", nlines = 1e5) + tmp <- read_txt_Renishaw(f_chondro, nlines = 1e5) expect_equal(dim(tmp), c(nrow = 875L, ncol = 4L, nwl = 1272L)) }) test_that("compressed files", { - skip("TODO: adapt to new package") - files <- Sys.glob("fileio/txt.Renishaw/chondro.*") + files <- Sys.glob(paste0(path, "/chondro.*")) files <- grep("[.]zip", files, invert = TRUE, value = TRUE) # .zip is tested with read_zip_Renishaw for (f in files) { expect_equal(dim(read_txt_Renishaw(!!f)), c(nrow = 875L, ncol = 4L, nwl = 1272L))