diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2017-01-27 01:00:07 +0100 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2017-01-27 02:17:41 +0100 |
commit | b38055278d4a801598ece9d2c93716a9bf67134a (patch) | |
tree | d1338a66115dd9c5bf5aa0004f16d8329093e852 /tests/testthat/test_TOXSWA.R | |
parent | 40c2f387775a168df1be699813807586cf098648 (diff) |
Set up FOCUS PELMO runs and run them in parallel
- This works on Linux using wine
- PELMO runs (including pelmo.inp files) are correctly generated
- The PLM files for FOCUS Pesticide_D in the test data archive are
correctly reproduced
- The data files (including FOCUS groundwater scenario data) are now
created and documented in R files
Diffstat (limited to 'tests/testthat/test_TOXSWA.R')
-rw-r--r-- | tests/testthat/test_TOXSWA.R | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/testthat/test_TOXSWA.R b/tests/testthat/test_TOXSWA.R new file mode 100644 index 0000000..7c9a73c --- /dev/null +++ b/tests/testthat/test_TOXSWA.R @@ -0,0 +1,56 @@ +library(pfm) +context("Read and analyse TOXSWA cwa files") + +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) + +basedir_test_2 = "SwashProjects/Project_1/TOXSWA" + +EXSW2_R1_stream <- read.TOXSWA_cwa("3.out", + basedir = basedir_test_2, + 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) + + EXSW2_R1_stream_printed <- capture.output(print(EXSW2_R1_stream)) + expect_equal(EXSW2_R1_stream_printed, readLines("EXSW2_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", { + + # 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") +}) |