Skip to content

Commit

Permalink
added tests for controls in probability_epidemic
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwlambert committed Dec 14, 2023
1 parent 4561566 commit 6c9eccb
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion tests/testthat/test-probability_epidemic.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test_that("probability_epidemic works for k == Inf", {
)
})

test_that("probability_epidemic works for different k & a", {
test_that("probability_epidemic works for different k & num_init_infect", {
res1 <- probability_epidemic(R = 1.5, k = 0.5, num_init_infect = 1)
res2 <- probability_epidemic(R = 1.5, k = 0.2, num_init_infect = 1)
res3 <- probability_epidemic(R = 1.5, k = 0.5, num_init_infect = 2)
Expand All @@ -36,6 +36,37 @@ test_that("probability_epidemic works for different k & a", {
expect_true((res4 < res3))
})

test_that("probability_epidemic works with individual-level control", {
expect_equal(
probability_epidemic(
R = 1.5, k = 0.5, num_init_infect = 1, ind_control = 0.2
),
0.091
)
})

test_that("probability_epidemic works with population-level control", {
expect_equal(
probability_epidemic(
R = 1.5, k = 0.5, num_init_infect = 1, pop_control = 0.2
),
0.113
)
})

test_that("probability_epidemic works with both control measures", {
expect_equal(
probability_epidemic(
R = 1.5,
k = 0.5,
num_init_infect = 1,
ind_control = 0.1,
pop_control = 0.1
),
0.108
)
})

test_that("probability_epidemic fails correctly", {
expect_error(
probability_epidemic(R = "1", k = 1, num_init_infect = 1),
Expand Down

0 comments on commit 6c9eccb

Please sign in to comment.