diff --git a/tests/testthat/test_sfcb.R b/tests/testthat/test_sfcb.R index faf89f15e3745f8140e4b13b59b8c6bfcc10c61d..f0868ca703251b7fd55b62b92e007a412bf71d68 100644 --- a/tests/testthat/test_sfcb.R +++ b/tests/testthat/test_sfcb.R @@ -91,3 +91,31 @@ test_that("`sfcb` works for one `at` with selection.", { range.at = c(5, 12)) expect_named(out14, expected_outputs) }) + +test_that("`sfcb` properly returns error when expected.", { + expect_error({sfcb(rainfall, truffles, at = "1")}, + "'at' must be a positive integer", fixed = FALSE) + expect_error({sfcb(rainfall, truffles, at = -3)}, + "'at' must be a positive integer", fixed = FALSE) + expect_error({sfcb(rainfall, truffles, at = 2.4)}, + "'at' must be a positive integer", fixed = FALSE) + + expect_error({sfcb(rainfall, truffles, range.at = 1:3)}, + "'range.at' must be a vector of minimum and maximum numbers", + fixed = FALSE) + expect_error({sfcb(rainfall, truffles, range.at = c("1", "2"))}, + "'range.at' must be a vector of minimum and maximum numbers", + fixed = FALSE) + expect_error({sfcb(rainfall, truffles, range.at = c(-1, 2))}, + "'range.at' must be a vector of minimum and maximum numbers", + fixed = FALSE) + expect_error({sfcb(rainfall, truffles, range.at = c(1.4, 2))}, + "'range.at' must be a vector of minimum and maximum numbers", + fixed = FALSE) + expect_error({sfcb(rainfall, truffles, range.at = c(5, 2))}, + "'range.at' must be a vector of minimum and maximum numbers", + fixed = FALSE) + + expect_error({sfcb(rainfall, truffles, seed = "1")}, + "'seed' must be numeric!", fixed = FALSE) +})