From 784bbe428a4e9a99a7ead9c38431e19da19fe0ee Mon Sep 17 00:00:00 2001 From: jamesaazam Date: Tue, 6 Feb 2024 13:47:50 +0000 Subject: [PATCH] Test for errors when switch statement does not match --- tests/testthat/test-helpers.R | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/testthat/test-helpers.R b/tests/testthat/test-helpers.R index 601561a1..7d05e736 100644 --- a/tests/testthat/test-helpers.R +++ b/tests/testthat/test-helpers.R @@ -27,6 +27,14 @@ test_that("update_chain_stat works correctly", { ), stat_latest + pmin(1, n_offspring) ) + expect_error( + .update_chain_stat( + stat_type = "foo", + stat_latest = stat_latest, + n_offspring = n_offspring + ), + "stat_type must be 'size' or 'length'" + ) }) test_that("get_statistic_func works correctly", { @@ -38,4 +46,8 @@ test_that("get_statistic_func works correctly", { .get_statistic_func(chain_statistic = "length"), rgen_length ) + expect_error( + .get_statistic_func(chain_statistic = "foo"), + "chain_statistic must be 'size' or 'length'" + ) })