From a3cbf4a5495e2da795265f3bf31978c08a43cac6 Mon Sep 17 00:00:00 2001 From: jamesaazam Date: Wed, 20 Sep 2023 16:13:46 +0100 Subject: [PATCH] Test for case when time is specified but not present in the data --- tests/testthat/test-epichains.R | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/testthat/test-epichains.R b/tests/testthat/test-epichains.R index dc8211ea..878d22ea 100644 --- a/tests/testthat/test-epichains.R +++ b/tests/testthat/test-epichains.R @@ -435,6 +435,22 @@ test_that("aggregate.epichains method returns correct objects", { ) }) +test_that("aggregate.epichains method throws errors", { + expect_error( + aggregate( + simulate_tree( + nchains = 10, + statistic = "size", + offspring_dist = "pois", + stat_max = 10, + lambda = 2 + ), + grouping_var = "time" + ), + "Object must have a time column" + ) +}) + test_that("aggregate.epichains method is numerically correct", { set.seed(12) #' Simulate a tree of infections without serials