From 4477e69b46e88c196f354463190753650157ea0d Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Fri, 21 Aug 2015 15:01:10 +0200 Subject: Updates to pass checks and tests --- pkg/tests/testthat/H_sw_D4_pond.rds | Bin 244540 -> 0 bytes pkg/tests/testthat/H_sw_D4_pond_printed.txt | 10 +++++++ pkg/tests/testthat/H_sw_R1_stream_events.rds | Bin 332 -> 334 bytes pkg/tests/testthat/H_sw_R1_stream_printed.txt | 10 +++++++ pkg/tests/testthat/H_sw_R1_stream_windows.rds | Bin 234 -> 235 bytes pkg/tests/testthat/test_TOXSWA_cwa.R | 39 ++++++++++++++++++-------- 6 files changed, 48 insertions(+), 11 deletions(-) delete mode 100644 pkg/tests/testthat/H_sw_D4_pond.rds create mode 100644 pkg/tests/testthat/H_sw_D4_pond_printed.txt create mode 100644 pkg/tests/testthat/H_sw_R1_stream_printed.txt (limited to 'pkg/tests/testthat') diff --git a/pkg/tests/testthat/H_sw_D4_pond.rds b/pkg/tests/testthat/H_sw_D4_pond.rds deleted file mode 100644 index 62c54bc..0000000 Binary files a/pkg/tests/testthat/H_sw_D4_pond.rds and /dev/null differ 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 @@ + 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 index 842c5de..ba6557b 100644 Binary files a/pkg/tests/testthat/H_sw_R1_stream_events.rds and b/pkg/tests/testthat/H_sw_R1_stream_events.rds differ 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 @@ + 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 index 29e13f2..2531189 100644 Binary files a/pkg/tests/testthat/H_sw_R1_stream_windows.rds and b/pkg/tests/testthat/H_sw_R1_stream_windows.rds differ 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)) -- cgit v1.2.1