diff options
| author | Johannes Ranke <jranke@uni-bremen.de> | 2015-08-21 15:12:12 +0200 |
|---|---|---|
| committer | Johannes Ranke <jranke@uni-bremen.de> | 2015-08-21 15:12:12 +0200 |
| commit | 405c10b443aacfe9aab15f4ab2797e92def9f246 (patch) | |
| tree | 93ef1669e31d403aa6334249d87a5f6f925313de /pkg/tests/testthat/test_TOXSWA_cwa.R | |
| parent | 7faffad1907995f1b623ede8fc2e386693428e22 (diff) | |
| parent | 5038ba57fef6cc386566ec30f3d5dd67e62decff (diff) | |
Merge branch 'master' into pfm_chent
Diffstat (limited to 'pkg/tests/testthat/test_TOXSWA_cwa.R')
| -rw-r--r-- | pkg/tests/testthat/test_TOXSWA_cwa.R | 39 |
1 files changed, 28 insertions, 11 deletions
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)) |
