Skip to content

Commit

Permalink
replace example with test
Browse files Browse the repository at this point in the history
  • Loading branch information
sbfnk committed Jul 3, 2023
1 parent 3867d5d commit 1c3de1a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
5 changes: 0 additions & 5 deletions R/get.R
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,6 @@ get_regions_with_most_reports <- function(reported_cases,
##' @param generation_time Generation time as specified using `dist_spec`
##' @return An integer seeding time
##' @author Sebastian Funk
##' @examples
##' gt1 <- dist_spec(mean = 5, sd = 1, max = 15)
##' gt2 <- dist_spec(mean = 10, sd = 2, max = 10)
##' delays <- dist_spec(mean = 5, sd = 1, max = 15)
##' get_seeding_time(delays, gt1 + gt2)
get_seeding_time <- function(delays, generation_time) {
# Estimate the mean delay -----------------------------------------------
seeding_time <- sum(mean(delays))
Expand Down
6 changes: 0 additions & 6 deletions man/get_seeding_time.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions tests/testthat/test-seeding-time.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
test_that("Seeding times are correctly calculated", {
gt1 <- dist_spec(mean = 5, sd = 1, max = 10)
gt2 <- dist_spec(mean = 10, sd = 2, max = 15)
delay1 <- dist_spec(mean = 5, sd = 1, max = 10)
delay2 <- dist_spec(mean = 7, sd = 3, max = 15)
expect_equal(get_seeding_time(delay1, gt1 + gt2), 23L) ## 10 + 15 - 1 - 1
expect_equal(get_seeding_time(delay1 + delay2, gt1), 12L) ## 5 + 7
})

test_that("Short seeding times are rounded up to 1", {
delay <- dist_spec(mean = 0.5, sd = 1, max = 2)
gt <- dist_spec(mean = 1)
expect_equal(get_seeding_time(delay, gt), 1L)
})

0 comments on commit 1c3de1a

Please sign in to comment.