aboutsummaryrefslogtreecommitdiff
path: root/pkg/tests/testthat/test_TOXSWA_cwa.R
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/tests/testthat/test_TOXSWA_cwa.R')
-rw-r--r--pkg/tests/testthat/test_TOXSWA_cwa.R25
1 files changed, 25 insertions, 0 deletions
diff --git a/pkg/tests/testthat/test_TOXSWA_cwa.R b/pkg/tests/testthat/test_TOXSWA_cwa.R
new file mode 100644
index 0000000..d91b79a
--- /dev/null
+++ b/pkg/tests/testthat/test_TOXSWA_cwa.R
@@ -0,0 +1,25 @@
+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"))
+ expect_equal_to_reference(H_sw_D4_pond, file = "H_sw_D4_pond.rds")
+})
+
+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))
+ expect_equal_to_reference(H_sw_R1_stream$events, file = "H_sw_R1_stream_events.rds")
+
+ # Moving window analysis
+ H_sw_R1_stream$moving_windows(c(7, 21))
+ expect_equal_to_reference(H_sw_R1_stream$windows, file = "H_sw_R1_stream_windows.rds")
+})

Contact - Imprint