diff options
| author | Johannes Ranke <johannes.ranke@jrwb.de> | 2026-02-06 17:39:23 +0100 |
|---|---|---|
| committer | Johannes Ranke <johannes.ranke@jrwb.de> | 2026-02-06 17:39:23 +0100 |
| commit | 10146dc469b218a97319fc4d49f12cb73cc9b5ba (patch) | |
| tree | 93d5c57e33446f81898e484b421e070c2a45a866 /tests/testthat | |
| parent | f0bf040afbadf07c21dc65495e344c0d2a25f9c3 (diff) | |
Support units in UK drainage calculations
Also, address some R CMD check notes
Diffstat (limited to 'tests/testthat')
| -rw-r--r-- | tests/testthat/test_UK_drainage.R | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/tests/testthat/test_UK_drainage.R b/tests/testthat/test_UK_drainage.R index defecbb..75d9c98 100644 --- a/tests/testthat/test_UK_drainage.R +++ b/tests/testthat/test_UK_drainage.R @@ -24,15 +24,23 @@ test_that("UK drainflow PECs are correct", { # This is the first example calculation from the data requirements handbook, where they give # 8.07 µg/L as the result (obviously a rounding error). - expect_equal(round(PEC_sw_drainage_UK(150, interception = 0, Koc = 100), 4), 8.0769) + expect_equal(round(PEC_sw_drainage_UK(150, interception = 0, Koc = 100), 4), + as_units(8.0769, "\u00B5g/L")) + + # Same as above, but using units for the input + expect_equal(round(PEC_sw_drainage_UK(as_units(0.15, "kg/ha"), interception = 0, + Koc = as_units(100, "mL/g")), 4), + as_units(8.0769, "\u00B5g/L")) # This is the second example calculation from the data requirements handbook - expect_equal(round(PEC_sw_drainage_UK(90, interception = 0, Koc = 10), 4), 13.1538) + expect_equal(round(PEC_sw_drainage_UK(90, interception = 0, Koc = 10), 4), + as_units(13.1538, "\u00B5g/L")) # This is the third example calculation from the data requirements handbook, expect_equal(round(PEC_sw_drainage_UK(60, interception = 0.5, Koc = 550, - latest_application = "01 July", - soil_DT50 = 200), 2), 0.84) + latest_application = "01 July", + soil_DT50 = 200), 2), + as_units(0.84, "\u00B5g/L")) expect_error(round(PEC_sw_drainage_UK(60, interception = 0.5, Koc = 550, latest_application = "100 July", @@ -42,6 +50,11 @@ test_that("UK drainflow PECs are correct", { latest_application = "29 February", soil_DT50 = 200), 2)) + expect_silent(round(PEC_sw_drainage_UK(60, interception = 0.5, Koc = 550, + latest_application = "29 February", + soil_DT50 = as_units(200, "d")), 2)) + + # Test that PECsw do not increase if the application is after the beginning # of the drainflow period expect_equal( |
