diff --git a/tests/testthat/_snaps/sim_network_bp.md b/tests/testthat/_snaps/sim_network_bp.md new file mode 100644 index 00000000..89a5fc03 --- /dev/null +++ b/tests/testthat/_snaps/sim_network_bp.md @@ -0,0 +1,45 @@ +# .sim_network_bp works as expected + + Code + .sim_network_bp(contact_distribution = contact_distribution, contact_interval = contact_interval, + prob_infect = 0.5, config = create_config()) + Output + id ancestor generation infected time + 1 1 NA 1 infected 0.00000000 + 2 2 1 2 contact 1.88240160 + 3 3 1 2 infected 1.80451250 + 4 4 3 3 infected 0.05896314 + 5 5 3 3 contact 1.15835525 + 6 6 3 3 contact 0.99001994 + 7 7 4 4 infected 2.14036129 + 8 8 7 5 contact 0.46988251 + 9 9 7 5 contact 0.69425308 + 10 10 7 5 contact 0.06819735 + +# .sim_network_bp works as expected with no contacts + + Code + .sim_network_bp(contact_distribution = contact_distribution, contact_interval = contact_interval, + prob_infect = 0.5, config = create_config()) + Output + id ancestor generation infected time + 1 1 NA 1 infected 0 + +# .sim_network_bp works as expected with unadjusted network + + Code + .sim_network_bp(contact_distribution = contact_distribution, contact_interval = contact_interval, + prob_infect = 0.5, config = create_config(network = "unadjusted")) + Output + id ancestor generation infected time + 1 1 NA 1 infected 0.00000000 + 2 2 1 2 contact 1.88240160 + 3 3 1 2 infected 1.80451250 + 4 4 3 3 infected 0.05896314 + 5 5 3 3 contact 1.15835525 + 6 6 3 3 contact 0.99001994 + 7 7 4 4 infected 2.14036129 + 8 8 7 5 contact 0.46988251 + 9 9 7 5 contact 0.69425308 + 10 10 7 5 contact 0.06819735 + diff --git a/tests/testthat/test-sim_network_bp.R b/tests/testthat/test-sim_network_bp.R index 6cbc6e2a..164de9e2 100644 --- a/tests/testthat/test-sim_network_bp.R +++ b/tests/testthat/test-sim_network_bp.R @@ -20,17 +20,13 @@ suppressMessages({ test_that(".sim_network_bp works as expected", { set.seed(1) - res <- .sim_network_bp( - contact_distribution = contact_distribution, - contact_interval = contact_interval, - prob_infect = 0.5, - config = create_config() - ) - expect_s3_class(res, class = "data.frame") - expect_identical(dim(res), c(10L, 5L)) - expect_identical( - colnames(res), - c("id", "ancestor", "generation", "infected", "time") + expect_snapshot( + .sim_network_bp( + contact_distribution = contact_distribution, + contact_interval = contact_interval, + prob_infect = 0.5, + config = create_config() + ) ) }) @@ -46,32 +42,24 @@ test_that(".sim_network_bp works as expected with no contacts", { ) ) set.seed(1) - res <- .sim_network_bp( - contact_distribution = contact_distribution, - contact_interval = contact_interval, - prob_infect = 0.5, - config = create_config() - ) - expect_s3_class(res, class = "data.frame") - expect_identical(dim(res), c(1L, 5L)) - expect_identical( - colnames(res), - c("id", "ancestor", "generation", "infected", "time") + expect_snapshot( + .sim_network_bp( + contact_distribution = contact_distribution, + contact_interval = contact_interval, + prob_infect = 0.5, + config = create_config() + ) ) }) test_that(".sim_network_bp works as expected with unadjusted network", { set.seed(1) - res <- .sim_network_bp( - contact_distribution = contact_distribution, - contact_interval = contact_interval, - prob_infect = 0.5, - config = create_config(network = "unadjusted") - ) - expect_s3_class(res, class = "data.frame") - expect_identical(dim(res), c(10L, 5L)) - expect_identical( - colnames(res), - c("id", "ancestor", "generation", "infected", "time") + expect_snapshot( + .sim_network_bp( + contact_distribution = contact_distribution, + contact_interval = contact_interval, + prob_infect = 0.5, + config = create_config(network = "unadjusted") + ) ) }) \ No newline at end of file