Skip to content

Commit

Permalink
Fix output test
Browse files Browse the repository at this point in the history
  • Loading branch information
plietar committed Jul 27, 2024
1 parent e1bc3c1 commit babc34b
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions tests/testthat/test-output.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ test_that('Test age parameter function works', {

sim <- run_simulation(timesteps = 1, parameters)

expect_true(
all(
paste0(rep(c("n_age",
"n", "n_inc", "p_inc",
"n","n_inc_clinical","p_inc_clinical",
"n","n_inc_severe","p_inc_severe",
"n","n_detect_lm","p_detect_lm","n_detect_pcr",
"ica_mean", "icm_mean","id_mean","ib_mean","iva_mean","ivm_mean"), each = 3),"_",
age_limits[-4]+rep(c(0,rep(c(1:3), each = 3), rep(4, 4), 5:10), each = 3),"_",age_limits[-1]-1+rep(c(0,rep(c(1:3), each = 3), rep(4, 4), 5:10), each = 3)
) %in%
names(sim)))
prefixes <- c("n_age",
"n_inc", "p_inc",
"n_inc_clinical","p_inc_clinical",
"n_inc_severe","p_inc_severe",
"n_detect_lm","p_detect_lm","n_detect_pcr",
"ica_mean", "icm_mean","id_mean","ib_mean","iva_mean","ivm_mean")
offsets <- c(0, rep(1, 2), rep(2, 2), rep(3, 2), rep(4, 3), 5:10)
expect_equal(length(prefixes), length(offsets))

expected <- paste0(rep(prefixes, each = 3),
"_", age_limits[-4]+rep(offsets, each = 3),
"_", age_limits[-1]-1+rep(offsets, each = 3))
expect_in(expected, names(sim))
})

0 comments on commit babc34b

Please sign in to comment.