Skip to content

Commit

Permalink
Create test-sis.R and populate with tests
Browse files Browse the repository at this point in the history
  • Loading branch information
apulsipher committed Nov 14, 2024
1 parent 061f026 commit cd3f06f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion inst/tinytest/test-multiple.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ saver <- make_saver(
run_multiple(
model_seircon,
ndays=days,
nsim=nsims,
nsims=nsims,
seed=1972,
saver=saver,
nthreads = 2L
Expand Down
34 changes: 34 additions & 0 deletions inst/tinytest/test-sis.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Test just this file: tinytest::run_test_file("inst/tinytest/test-sis.R")

# Create small world population SIS Model --------------------------------------
expect_silent(sis_0 <- ModelSIS(
name = "SIS",
prevalence = .1,
transmission_rate = .3,
recovery_rate = .3
))

# Check model initialization
expect_inherits(sis_0, "epiworld_sis")
expect_inherits(sis_0, "epiworld_model")
expect_silent(agents_smallworld(
sis_0,
n = 2000,
k = 5,
d = FALSE,
p = .01
))

# Check model run --------------------------------------------------------------
expect_silent(verbose_off(sis_0))
expect_warning(expect_error(plot(sis_0))) # Plot fails before model is run
expect_silent(run_multiple(
sis_0,
ndays=100,
nsims=10,
seed=1231,
reset=TRUE,
verbose = TRUE,
nthreads = 1
))
expect_silent(plot(sis_0)) # Plot succeeds after model is run

0 comments on commit cd3f06f

Please sign in to comment.