Skip to content

Commit

Permalink
full coverage for simulate_age
Browse files Browse the repository at this point in the history
  • Loading branch information
Spatiotemporal-Exposures-and-Toxicology committed Jan 6, 2024
1 parent f5ccf07 commit 5169dbb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
1 change: 0 additions & 1 deletion _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
url: https://spatiotemporal-exposures-and-toxicology.github.io/GeoToxPackage/
template:
bootstrap: 5
bootswatch: sandstone

22 changes: 21 additions & 1 deletion tests/testthat/test-simulate_age.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
test_that("inputs", {
test_that("simulate_age returns errors from bad inputs", {
# errors from bad input
expect_error(simulate_age(data.frame()))
# errors from bad order
expect_error(simulate_age(data.frame(AGEGRP = 0, TOT_POP = 0)))
#
})


test_that("age samples are good", {

x <- data.frame(AGEGRP = 0:18, TOT_POP = c(sum(1:18), 1:18))
ages_test <- simulate_age(x, 10)


# age sample is of size "n"
expect_vector(ages_test,size = 10)

# age samples are within allowed age range [0,90] t
expect_true(all(ages_test < 90 & ages_test >= 0))


#
})

0 comments on commit 5169dbb

Please sign in to comment.