test_that("SIR works", { withr::local_seed(20231029) g <- sample_gnm(50, 50) res <- sir(g, beta = 5, gamma = 1, no.sim = 10) expect_length(res, 10) expect_length(unique(lengths(res[[1]])), 1) expect_true(all(diff(res[[1]]$times) > 0)) expect_true(all(res[[1]]$NS >= 0)) expect_true(all(res[[1]]$NI >= 0)) expect_true(all(res[[1]]$NR >= 0)) expect_true(all(diff(res[[1]]$NS) <= 0)) expect_true(all(diff(res[[1]]$NR) >= 0)) expect_true(all(res[[1]]$NS + res[[1]]$NI + res[[1]]$NR == 50)) expect_length(unique(lengths(res[[2]])), 1) expect_true(all(diff(res[[2]]$times) > 0)) expect_true(all(res[[2]]$NS >= 0)) expect_true(all(res[[2]]$NI >= 0)) expect_true(all(res[[2]]$NR >= 0)) expect_true(all(diff(res[[2]]$NS) <= 0)) expect_true(all(diff(res[[2]]$NR) >= 0)) expect_true(all(res[[2]]$NS + res[[2]]$NI + res[[2]]$NR == 50)) expect_length(unique(lengths(res[[3]])), 1) expect_true(all(diff(res[[3]]$times) > 0)) expect_true(all(res[[3]]$NS >= 0)) expect_true(all(res[[3]]$NI >= 0)) expect_true(all(res[[3]]$NR >= 0)) expect_true(all(diff(res[[3]]$NS) <= 0)) expect_true(all(diff(res[[3]]$NR) >= 0)) expect_true(all(res[[3]]$NS + res[[3]]$NI + res[[3]]$NR == 50)) expect_length(unique(lengths(res[[4]])), 1) expect_true(all(diff(res[[4]]$times) > 0)) expect_true(all(res[[4]]$NS >= 0)) expect_true(all(res[[4]]$NI >= 0)) expect_true(all(res[[4]]$NR >= 0)) expect_true(all(diff(res[[4]]$NS) <= 0)) expect_true(all(diff(res[[4]]$NR) >= 0)) expect_true(all(res[[4]]$NS + res[[4]]$NI + res[[4]]$NR == 50)) expect_length(unique(lengths(res[[5]])), 1) expect_true(all(diff(res[[5]]$times) > 0)) expect_true(all(res[[5]]$NS >= 0)) expect_true(all(res[[5]]$NI >= 0)) expect_true(all(res[[5]]$NR >= 0)) expect_true(all(diff(res[[5]]$NS) <= 0)) expect_true(all(diff(res[[5]]$NR) >= 0)) expect_true(all(res[[5]]$NS + res[[5]]$NI + res[[5]]$NR == 50)) expect_length(unique(lengths(res[[6]])), 1) expect_true(all(diff(res[[6]]$times) > 0)) expect_true(all(res[[6]]$NS >= 0)) expect_true(all(res[[6]]$NI >= 0)) expect_true(all(res[[6]]$NR >= 0)) expect_true(all(diff(res[[6]]$NS) <= 0)) expect_true(all(diff(res[[6]]$NR) >= 0)) expect_true(all(res[[6]]$NS + res[[6]]$NI + res[[6]]$NR == 50)) expect_length(unique(lengths(res[[7]])), 1) expect_true(all(diff(res[[7]]$times) > 0)) expect_true(all(res[[7]]$NS >= 0)) expect_true(all(res[[7]]$NI >= 0)) expect_true(all(res[[7]]$NR >= 0)) expect_true(all(diff(res[[7]]$NS) <= 0)) expect_true(all(diff(res[[7]]$NR) >= 0)) expect_true(all(res[[7]]$NS + res[[7]]$NI + res[[7]]$NR == 50)) expect_length(unique(lengths(res[[8]])), 1) expect_true(all(diff(res[[8]]$times) > 0)) expect_true(all(res[[8]]$NS >= 0)) expect_true(all(res[[8]]$NI >= 0)) expect_true(all(res[[8]]$NR >= 0)) expect_true(all(diff(res[[8]]$NS) <= 0)) expect_true(all(diff(res[[8]]$NR) >= 0)) expect_true(all(res[[8]]$NS + res[[8]]$NI + res[[8]]$NR == 50)) expect_length(unique(lengths(res[[9]])), 1) expect_true(all(diff(res[[9]]$times) > 0)) expect_true(all(res[[9]]$NS >= 0)) expect_true(all(res[[9]]$NI >= 0)) expect_true(all(res[[9]]$NR >= 0)) expect_true(all(diff(res[[9]]$NS) <= 0)) expect_true(all(diff(res[[9]]$NR) >= 0)) expect_true(all(res[[9]]$NS + res[[9]]$NI + res[[9]]$NR == 50)) expect_length(unique(lengths(res[[10]])), 1) expect_true(all(diff(res[[10]]$times) > 0)) expect_true(all(res[[10]]$NS >= 0)) expect_true(all(res[[10]]$NI >= 0)) expect_true(all(res[[10]]$NR >= 0)) expect_true(all(diff(res[[10]]$NS) <= 0)) expect_true(all(diff(res[[10]]$NR) >= 0)) expect_true(all(res[[10]]$NS + res[[10]]$NI + res[[10]]$NR == 50)) })