diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2022-03-01 16:59:30 +0100 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2022-03-01 17:56:11 +0100 |
commit | 1ba0938b5a39f9d376b54fe3469b40aafea9e8e3 (patch) | |
tree | 4e7e67855246d59a04d2eb0f18646fcc9460e020 /tests | |
parent | ccae8c02b1e6a30911b9d1efdb388f30f9c9cb78 (diff) |
Avoid using cat() for default output, tests
Diffstat (limited to 'tests')
-rw-r--r-- | tests/testthat/test_f_time_norm.R | 7 | ||||
-rw-r--r-- | tests/testthat/test_mkinfit.R | 10 |
2 files changed, 13 insertions, 4 deletions
diff --git a/tests/testthat/test_f_time_norm.R b/tests/testthat/test_f_time_norm.R index c5e0607c..d5b89902 100644 --- a/tests/testthat/test_f_time_norm.R +++ b/tests/testthat/test_f_time_norm.R @@ -5,13 +5,12 @@ test_that("Simple temperature and moisture normalisation works", { }) test_that("Time step normalisation for a dataset works", { - expect_output(f_time_norm_focus(D24_2014, study_moisture_ref_source = "focus", f_na = 1), - "was set to") + expect_message(f_time_norm_focus(D24_2014, study_moisture_ref_source = "focus", f_na = 1)) expect_equal(round(D24_2014$f_time_norm, 3), c(1.606, 0.712, 0.716, 0.716, 0.898)) - expect_output(f_time_norm_focus(dimethenamid_2018), "was set to") + expect_message(f_time_norm_focus(dimethenamid_2018)) # Reference values from Dimethenamid RAR 2018 Vol3 B.8 - expect_equal(round(dimethenamid_2018$f_time_norm, 3), + expect_equal(round(dimethenamid_2018$f_time_norm, 3), c(1, 0.971, # p. 56 rep(round(1.329 * 0.924, 3), 2), # p. 51 diff --git a/tests/testthat/test_mkinfit.R b/tests/testthat/test_mkinfit.R index fb81c3d8..11b6111a 100644 --- a/tests/testthat/test_mkinfit.R +++ b/tests/testthat/test_mkinfit.R @@ -8,3 +8,13 @@ test_that("Specifying initial values for state variables works correctly", { # also affecting AIC calculations expect_equal(logLik(f_1), logLik(f_2)) }) + +test_that("We get messages and output from mkinfit if desired", { + # For progress info we use message() + expect_message(mkinfit("SFO", FOCUS_2006_A, quiet = FALSE)) + + # trace_parms uses cat() + out <- capture.output( + tmp <- mkinfit("SFO", FOCUS_2006_A, trace_parms = TRUE, quiet = TRUE)) + expect_true(length(out) > 10) +}) |