diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2015-04-22 13:42:10 +0200 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2015-04-22 13:42:10 +0200 |
commit | ec79637749d300ab4ca170805c673905e52d67dd (patch) | |
tree | 6eabf636f3012daecbe7ee446b1083da86d64e63 /pkg/tests/testthat | |
parent | 8ffbc49b3f01deac6f9e83aaa6d318d4e2f8552b (diff) |
Add simplest PEC soil calcs, use testthat
Diffstat (limited to 'pkg/tests/testthat')
-rw-r--r-- | pkg/tests/testthat/H_sw_D4_pond.rds | bin | 0 -> 243113 bytes | |||
-rw-r--r-- | pkg/tests/testthat/H_sw_R1_stream_events.rds | bin | 0 -> 332 bytes | |||
-rw-r--r-- | pkg/tests/testthat/H_sw_R1_stream_windows.rds | bin | 0 -> 234 bytes | |||
-rw-r--r-- | pkg/tests/testthat/test_PEC_soil.R | 13 | ||||
-rw-r--r-- | pkg/tests/testthat/test_TOXSWA_cwa.R | 25 |
5 files changed, 38 insertions, 0 deletions
diff --git a/pkg/tests/testthat/H_sw_D4_pond.rds b/pkg/tests/testthat/H_sw_D4_pond.rds Binary files differnew file mode 100644 index 0000000..9ad8194 --- /dev/null +++ b/pkg/tests/testthat/H_sw_D4_pond.rds diff --git a/pkg/tests/testthat/H_sw_R1_stream_events.rds b/pkg/tests/testthat/H_sw_R1_stream_events.rds Binary files differnew file mode 100644 index 0000000..3e2828e --- /dev/null +++ b/pkg/tests/testthat/H_sw_R1_stream_events.rds diff --git a/pkg/tests/testthat/H_sw_R1_stream_windows.rds b/pkg/tests/testthat/H_sw_R1_stream_windows.rds Binary files differnew file mode 100644 index 0000000..29e13f2 --- /dev/null +++ b/pkg/tests/testthat/H_sw_R1_stream_windows.rds diff --git a/pkg/tests/testthat/test_PEC_soil.R b/pkg/tests/testthat/test_PEC_soil.R new file mode 100644 index 0000000..27b2eb7 --- /dev/null +++ b/pkg/tests/testthat/test_PEC_soil.R @@ -0,0 +1,13 @@ +library(pfm) +context("Simple PEC soil calculations") + +test_that("PEC_soil calculates correctly", { + # Application of 100 g/ha gives 0.133 mg/kg under default assumptions + expect_equal(PEC_soil(100), 0.1 * 4/3) + + # or 0.1 mg/kg assuming 25% interception + expect_equal(PEC_soil(100, interception = 0.25), 0.1) + + # Mixing depth of 1 cm gives five-fold PEC + expect_equal(PEC_soil(100, interception = 0.25, mixing_depth = 1), 0.5) +}) 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") +}) |