Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

full coverage for simulate_age #22

Merged
merged 1 commit into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))


#
})