diff --git a/R/model_diphtheria.R b/R/model_diphtheria.R index 26da4c1a..fe234464 100644 --- a/R/model_diphtheria.R +++ b/R/model_diphtheria.R @@ -175,6 +175,12 @@ model_diphtheria_cpp <- function(population, population_change, null.ok = TRUE, len = 2L, types = c("numeric", "list") ) + if (!is.null(population_change)) { + checkmate::assert_names( + names(population_change), + identical.to = c("time", "values") + ) + } # check the time end and increment # restrict increment to lower limit of 1e-6 diff --git a/tests/testthat/test-model_diphtheria.R b/tests/testthat/test-model_diphtheria.R index b4e7b314..19578469 100644 --- a/tests/testthat/test-model_diphtheria.R +++ b/tests/testthat/test-model_diphtheria.R @@ -52,11 +52,11 @@ test_that("Diptheria model, basic expectations", { # check for identical numbers of individuals at start and end # NOTE: high tolerance because hospitalised compartment is not directly # linked to infectious compartment per Finger et al. model structure. - # leads to more individuals at final state than initial state + # leads to different individuals at final state than initial state expect_identical( sum(output[output$time == min(output$time), ]$value), sum(output[output$time == max(output$time), ]$value), - tolerance = 100 + tolerance = 1e-6 ) # check that all age groups in the simulation are the same # size as the demography vector