From 0712992c80d5cb24a38efa3d9ecde50bf385db67 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 2 Dec 2024 18:38:25 +0000 Subject: [PATCH] add some tests for the generic transform data method --- tests/test-transform_data.R | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/test-transform_data.R diff --git a/tests/test-transform_data.R b/tests/test-transform_data.R new file mode 100644 index 000000000..a970d8652 --- /dev/null +++ b/tests/test-transform_data.R @@ -0,0 +1,39 @@ +test_that( + "epidist_transform_data with default settings returns data unchanged", + { + family <- epidist_family(prep_obs, family = lognormal()) + formula <- epidist_formula(prep_obs, family = family, formula = bf(mu ~ 1)) + + transformed <- epidist_transform_data(prep_obs, family, formula) + expect_identical(transformed, prep_obs) + } +) + +test_that("epidist_transform_data errors when passed incorrect inputs", { + family <- epidist_family(prep_obs, family = lognormal()) + formula <- epidist_formula(prep_obs, family = family, formula = bf(mu ~ 1)) + + expect_error(epidist_transform_data(list(), family, formula)) +}) + +test_that("epidist_transform_data_model.default returns data unchanged", { + family <- epidist_family(prep_obs, family = lognormal()) + formula <- epidist_formula(prep_obs, family = family, formula = bf(mu ~ 1)) + + transformed <- epidist_transform_data_model(prep_obs, family, formula) + expect_identical(transformed, prep_obs) +}) + +test_that("epidist_transform_data works with different model types", { + family <- epidist_family(prep_obs, family = lognormal()) + formula <- epidist_formula(prep_obs, family = family, formula = bf(mu ~ 1)) + + expect_identical( + epidist_transform_data(prep_naive_obs, family, formula), + prep_naive_obs + ) + expect_identical( + epidist_transform_data(prep_obs_gamma, family, formula), + prep_obs_gamma + ) +})