Skip to content

Commit

Permalink
created tests for crowding and education
Browse files Browse the repository at this point in the history
  • Loading branch information
realbp committed Feb 7, 2024
1 parent ae59e9e commit 8ab2ede
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
3 changes: 3 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ Imports:
stringr,
tibble,
utils
Suggests:
testthat (>= 3.0.0)
Config/testthat/edition: 3
12 changes: 12 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file is part of the standard setup for testthat.
# It is recommended that you do not modify it.
#
# Where should you do additional test configuration?
# Learn more about the roles of various files in:
# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview
# * https://testthat.r-lib.org/articles/special-files.html

library(testthat)
library(cancerprof)

test_check("cancerprof")
13 changes: 13 additions & 0 deletions tests/testthat/test-demo-crowding.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
test_that("demo-crowding", {
test_crowding1 <- demo_crowding("WA", "hsa", "All Races (includes Hispanic)")


# object, length, dimensions,
# ranges -ex: greater than 10 rows
# errors
#
expect_type(test_crowding1, "list")


#expect_error() - catches an expected error
})
15 changes: 15 additions & 0 deletions tests/testthat/test-demo-education.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
test_that("demo-education", {
test_education1 <- demo_education("wa", "county", "at least high school", "males")

expect_type(test_education1, "list")


expect_error(
demo_education("wa", "county", "less than 9th grade", "males"),
"For Less than 9th Grade, Race and Sex must be NULL"
)
expect_error(
demo_education("wa", "county", "at least high school", "all races (includes hispanic", "females"),
"For At Least High School, Race must be NULL and Sex must be NOT NULL"
)
})

0 comments on commit 8ab2ede

Please sign in to comment.