diff options
Diffstat (limited to 'pkg/tests')
-rw-r--r-- | pkg/tests/testthat/H_sw_D4_pond.rds | bin | 244540 -> 0 bytes | |||
-rw-r--r-- | pkg/tests/testthat/H_sw_D4_pond_printed.txt | 10 | ||||
-rw-r--r-- | pkg/tests/testthat/H_sw_R1_stream_events.rds | bin | 332 -> 334 bytes | |||
-rw-r--r-- | pkg/tests/testthat/H_sw_R1_stream_printed.txt | 10 | ||||
-rw-r--r-- | pkg/tests/testthat/H_sw_R1_stream_windows.rds | bin | 234 -> 235 bytes | |||
-rw-r--r-- | pkg/tests/testthat/test_TOXSWA_cwa.R | 39 |
6 files changed, 48 insertions, 11 deletions
diff --git a/pkg/tests/testthat/H_sw_D4_pond.rds b/pkg/tests/testthat/H_sw_D4_pond.rds Binary files differdeleted file mode 100644 index 62c54bc..0000000 --- a/pkg/tests/testthat/H_sw_D4_pond.rds +++ /dev/null diff --git a/pkg/tests/testthat/H_sw_D4_pond_printed.txt b/pkg/tests/testthat/H_sw_D4_pond_printed.txt new file mode 100644 index 0000000..5730be6 --- /dev/null +++ b/pkg/tests/testthat/H_sw_D4_pond_printed.txt @@ -0,0 +1,10 @@ +<TOXSWA_cwa> data from file 00001p_pa.cwa segment 1 + datetime t t_firstjan t_rel_to_max cwa_mug_per_L cwa_tot_mug_per_L +1 1985-01-01 00:00:00 0.000 0.00000000 -396.167 0.00000000 0.00000000 +2 1985-01-01 01:00:00 0.042 0.04166667 -396.125 0.08323064 0.08323716 +3 1985-01-01 02:00:00 0.083 0.08333333 -396.084 0.16626900 0.16628210 +4 1985-01-01 03:00:00 0.125 0.12500000 -396.042 0.24911240 0.24913190 +5 1985-01-01 04:00:00 0.167 0.16666667 -396.000 0.33172050 0.33174650 +6 1985-01-01 05:00:00 0.208 0.20833333 -395.959 0.41401430 0.41404670 +Moving window analysis +NULL diff --git a/pkg/tests/testthat/H_sw_R1_stream_events.rds b/pkg/tests/testthat/H_sw_R1_stream_events.rds Binary files differindex 842c5de..ba6557b 100644 --- a/pkg/tests/testthat/H_sw_R1_stream_events.rds +++ b/pkg/tests/testthat/H_sw_R1_stream_events.rds diff --git a/pkg/tests/testthat/H_sw_R1_stream_printed.txt b/pkg/tests/testthat/H_sw_R1_stream_printed.txt new file mode 100644 index 0000000..572ad6d --- /dev/null +++ b/pkg/tests/testthat/H_sw_R1_stream_printed.txt @@ -0,0 +1,10 @@ +<TOXSWA_cwa> data from file 00003s_pa.cwa segment 20 + datetime t t_firstjan t_rel_to_max cwa_mug_per_L cwa_tot_mug_per_L +20 1978-10-01 00:00:00 0.000 273.0000 -55.333 0 0 +40 1978-10-01 01:00:00 0.042 273.0417 -55.291 0 0 +60 1978-10-01 02:00:00 0.083 273.0833 -55.250 0 0 +80 1978-10-01 03:00:00 0.125 273.1250 -55.208 0 0 +100 1978-10-01 04:00:00 0.167 273.1667 -55.166 0 0 +120 1978-10-01 05:00:00 0.208 273.2083 -55.125 0 0 +Moving window analysis +NULL diff --git a/pkg/tests/testthat/H_sw_R1_stream_windows.rds b/pkg/tests/testthat/H_sw_R1_stream_windows.rds Binary files differindex 29e13f2..2531189 100644 --- a/pkg/tests/testthat/H_sw_R1_stream_windows.rds +++ b/pkg/tests/testthat/H_sw_R1_stream_windows.rds diff --git a/pkg/tests/testthat/test_TOXSWA_cwa.R b/pkg/tests/testthat/test_TOXSWA_cwa.R index 582c51e..407a7a1 100644 --- a/pkg/tests/testthat/test_TOXSWA_cwa.R +++ b/pkg/tests/testthat/test_TOXSWA_cwa.R @@ -1,20 +1,37 @@ library(pfm) context("Read and analyse TOXSWA cwa files") -test_that("TOXSWA cwa file is correctly read", { - H_sw_D4_pond <- read.TOXSWA_cwa("00001p_pa.cwa", - basedir = "SwashProjects/project_H_sw/TOXSWA", - zipfile = system.file("testdata/SwashProjects.zip", - package = "pfm")) - H_sw_D4_pond$zipfile <- NULL # do not test the path - expect_equal_to_reference(H_sw_D4_pond, file = "H_sw_D4_pond.rds") +zipfile_test = system.file("testdata/SwashProjects.zip", package = "pfm") +basedir_test = "SwashProjects/project_H_sw/TOXSWA" + +H_sw_D4_pond <- read.TOXSWA_cwa("00001p_pa.cwa", + basedir = basedir_test, + zipfile = zipfile_test) + +H_sw_R1_stream <- read.TOXSWA_cwa("00003s_pa.cwa", + basedir = basedir_test, + zipfile = zipfile_test) + + +test_that("TOXSWA cwa file is correctly read and printed", { + + # This was the setting when printing the output into text files + options(width = 100) + + # Most content of the R6 object is at least partially printed + + H_sw_D4_pond_printed <- capture.output(print(H_sw_D4_pond)) + + expect_equal(H_sw_D4_pond_printed, readLines("H_sw_D4_pond_printed.txt")) + + H_sw_R1_stream_printed <- capture.output(print(H_sw_R1_stream)) + expect_equal(H_sw_R1_stream_printed, readLines("H_sw_R1_stream_printed.txt")) + + # The basedir is not printed, therefore tested separately + expect_equal(H_sw_D4_pond$basedir, basedir_test) }) test_that("Getting events and moving window analysis works", { - H_sw_R1_stream <- read.TOXSWA_cwa("00003s_pa.cwa", - basedir = "SwashProjects/project_H_sw/TOXSWA", - zipfile = system.file("testdata/SwashProjects.zip", - package = "pfm")) # Event analysis with two different thresholds H_sw_R1_stream$get_events(c(2, 10)) |