-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from getwilds/test
Test
- Loading branch information
Showing
27 changed files
with
337 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#' Test Handle age | ||
#' | ||
#' This testthat file tests the handle-age function | ||
test_that("handle age correctly maps age", { | ||
result <- sapply(c("under 19 years", "under 65 years", "all ages"), handle_age) | ||
expected <- c(`under 19 years` = "175", `under 65 years` = "006", `all ages` = "001") | ||
|
||
expect_equal(result, expected) | ||
}) | ||
|
||
test_that("handle age expects errors for incorrect arguments", { | ||
expect_error(handle_age("carrot")) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#' Test Handle alcohol | ||
#' | ||
#' This testthat file tests the handle-age function | ||
test_that("handle_alcohol correctly maps alcohol", { | ||
result <- sapply(c("binge drinking (4+ drinks on one occasion for women, 5+ drinks for one occasion for men), ages 21+"), handle_alcohol) | ||
expected <- c(`binge drinking (4+ drinks on one occasion for women, 5+ drinks for one occasion for men), ages 21+` = "v505") | ||
|
||
expect_equal(result, expected) | ||
}) | ||
|
||
test_that("handle_alcohol expects errors for incorrect arguments", { | ||
expect_error(handle_alcohol("carrot")) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#' Test Handle cancer | ||
#' | ||
#' This testthat file tests the handle-cancer function | ||
test_that("handle cancer correctly maps cancer", { | ||
result <- sapply(c("all cancer sites", "breast (female)", "prostate"), handle_cancer) | ||
expected <- c(`all cancer sites` = "001", `breast (female)` = "055", `prostate` = "066") | ||
|
||
expect_equal(result, expected) | ||
}) | ||
|
||
test_that("handle cancer expects errors for incorrect arguments", { | ||
expect_error(handle_cancer("carrot")) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#' Test Handle diet_exercise | ||
#' | ||
#' This testthat file tests the handle-diet_exercise function | ||
test_that("handle diet_exercise correctly maps diet_exercise", { | ||
result <- sapply(c("bmi is healthy, ages 20+", "bmi is obese, ages 20+", | ||
"consumed 1 or more fruits per day"), handle_diet_exercise) | ||
expected <- c(`bmi is healthy, ages 20+` = "v01", `bmi is obese, ages 20+` = "v02", | ||
`consumed 1 or more fruits per day` = "v50") | ||
|
||
expect_equal(result, expected) | ||
}) | ||
|
||
test_that("handle diet_exercise expects errors for incorrect arguments", { | ||
expect_error(handle_diet_exercise("carrot")) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#' Test Handle education | ||
#' | ||
#' This testthat file tests the handle-education function | ||
test_that("handle education correctly maps education", { | ||
result <- sapply(c("less than 9th grade", "at least high school", | ||
"at least bachelors degree"), handle_education) | ||
expected <- c(`less than 9th grade` = "00004", `at least high school` = "00109", | ||
`at least bachelors degree` = "00006") | ||
|
||
expect_equal(result, expected) | ||
}) | ||
|
||
test_that("handle education expects errors for incorrect arguments", { | ||
expect_error(handle_education("carrot")) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#' Test Handle food | ||
#' | ||
#' This testthat file tests the handle-food function | ||
test_that("handle food correctly maps food", { | ||
result <- sapply(c("food insecurity", "limited access to healthy food"), handle_food) | ||
expected <- c(`food insecurity` = "03003", `limited access to healthy food` = "03004") | ||
|
||
expect_equal(result, expected) | ||
}) | ||
|
||
test_that("handle food expects errors for incorrect arguments", { | ||
expect_error(handle_food("carrot")) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#' Test Handle income | ||
#' | ||
#' This testthat file tests the handle-income function | ||
test_that("handle income correctly maps income", { | ||
result <- sapply(c("median family income", "median household income"), handle_income) | ||
expected <- c(`median family income` = "00010", `median household income` = "00011") | ||
|
||
expect_equal(result, expected) | ||
}) | ||
|
||
test_that("handle income expects errors for incorrect arguments", { | ||
expect_error(handle_income("carrot")) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#' Test Handle insurance | ||
#' | ||
#' This testthat file tests the handle-insurance function | ||
test_that("handle insurance correctly maps insurance", { | ||
result <- sapply(c("% insured in demographic group, all income levels", | ||
"% uninsured in demographic group, all income levels", | ||
"% insured in demographic group, people at or below 138% of poverty"), | ||
handle_insurance) | ||
expected <- c(`% insured in demographic group, all income levels` = "00030", | ||
`% uninsured in demographic group, all income levels` = "00040", | ||
`% insured in demographic group, people at or below 138% of poverty` = "00033") | ||
|
||
expect_equal(result, expected) | ||
}) | ||
|
||
test_that("handle insurance expects errors for incorrect arguments", { | ||
expect_error(handle_insurance("carrot")) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#' Test Handle mobility | ||
#' | ||
#' This testthat file tests the handle-mobility function | ||
test_that("handle mobility correctly maps mobility", { | ||
result <- sapply(c("i haven't moved (in past year)", | ||
"moved from outside us (in past year)", | ||
"moved, same county (in past year)"), handle_mobility) | ||
expected <- c(`i haven't moved (in past year)` = "00017", | ||
`moved from outside us (in past year)` = "00021", | ||
`moved, same county (in past year)` = "00018") | ||
|
||
expect_equal(result, expected) | ||
}) | ||
|
||
test_that("handle mobility expects errors for incorrect arguments", { | ||
expect_error(handle_mobility("carrot")) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#' Test Handle population | ||
#' | ||
#' This testthat file tests the handle-population function | ||
test_that("handle population correctly maps population", { | ||
result <- sapply(c("age under 18", "foreign born", "males"), handle_population) | ||
expected <- c(`age under 18` = "00002", `foreign born` = "00014", `males` = "00104") | ||
|
||
expect_equal(result, expected) | ||
}) | ||
|
||
test_that("handle population expects errors for incorrect arguments", { | ||
expect_error(handle_population("carrot")) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#' Test Handle poverty | ||
#' | ||
#' This testthat file tests the handle-poverty function | ||
test_that("handle poverty correctly maps poverty", { | ||
result <- sapply(c("families below poverty", "persistent poverty", | ||
"persons below poverty"), handle_poverty) | ||
expected <- c(`families below poverty` = "00007", `persistent poverty` = "03001", | ||
`persons below poverty` = "00008") | ||
|
||
expect_equal(result, expected) | ||
}) | ||
|
||
test_that("handle poverty expects errors for incorrect arguments", { | ||
expect_error(handle_poverty("carrot")) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#' Test Handle race | ||
#' | ||
#' This testthat file tests the handle-race function | ||
test_that("handle race correctly maps race", { | ||
result <- sapply(c("all races (includes hispanic)", "white (non-hispanic)", | ||
"asian non-hispanic"), handle_race) | ||
expected <- c(`all races (includes hispanic)` = "00", | ||
`white (non-hispanic)` = "07", | ||
`asian non-hispanic` = "49") | ||
|
||
expect_equal(result, expected) | ||
}) | ||
|
||
test_that("handle race expects errors for incorrect arguments", { | ||
expect_error(handle_race("carrot")) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#' Test Handle datatype | ||
#' | ||
#' This testthat file tests the handle-datatype function | ||
test_that("handle datatype correctly maps datatype", { | ||
result <- sapply(c("direct estimates", "county level modeled estimates"), handle_datatype) | ||
expected <- c(`direct estimates` = "0", `county level modeled estimates` = "1") | ||
|
||
expect_equal(result, expected) | ||
}) | ||
|
||
test_that("handle datatype expects errors for incorrect arguments", { | ||
expect_error(handle_datatype("carrot")) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#' Test Handle screening | ||
#' | ||
#' This testthat file tests the handle-screening function | ||
test_that("handle screening correctly maps screening", { | ||
result <- sapply(c("ever had fobt, ages 50-75", | ||
"guidance sufficient crc, ages 50-75", | ||
"home blood stool test in the past year, ages 45-75"), handle_screening) | ||
expected <- c(`ever had fobt, ages 50-75` = "v304", | ||
`guidance sufficient crc, ages 50-75` = "v303", | ||
`home blood stool test in the past year, ages 45-75` = "v520") | ||
|
||
expect_equal(result, expected) | ||
}) | ||
|
||
test_that("handle screening expects errors for incorrect arguments", { | ||
expect_error(handle_screening("carrot")) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#' Test Handle smoking | ||
#' | ||
#' This testthat file tests the handle-smoking function | ||
test_that("handle smoking correctly maps age", { | ||
result <- sapply(c("smokers (current); ages 18+", | ||
"smokers (ever); ages 18+", | ||
"smoking laws (any)"), handle_smoking) | ||
expected <- c(`smokers (current); ages 18+` = "v19", | ||
`smokers (ever); ages 18+` = "v28", | ||
`smoking laws (any)` = "v44") | ||
|
||
expect_equal(result, expected) | ||
}) | ||
|
||
test_that("handle smoking expects errors for incorrect arguments", { | ||
expect_error(handle_smoking("carrot")) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#' Test Handle stage | ||
#' | ||
#' This testthat file tests the handle-stage function | ||
test_that("handle stage correctly maps stage", { | ||
result <- sapply(c("all stages", "late stage (regional & distant)"), handle_stage) | ||
expected <- c(`all stages` = "999", `late stage (regional & distant)` = "211") | ||
|
||
expect_equal(result, expected) | ||
}) | ||
|
||
test_that("handle stage expects errors for incorrect arguments", { | ||
expect_error(handle_stage("carrot")) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#' Test Handle svi | ||
#' | ||
#' This testthat file tests the handle-svi function | ||
test_that("handle svi correctly maps svi", { | ||
result <- sapply(c("overall", "socioeconomic status", | ||
"household characteristics"), handle_svi) | ||
expected <- c(`overall` = "03010", `socioeconomic status` = "03011", | ||
`household characteristics` = "03012") | ||
|
||
expect_equal(result, expected) | ||
}) | ||
|
||
test_that("handle svi expects errors for incorrect arguments", { | ||
expect_error(handle_svi("carrot")) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#' Test Handle vaccine | ||
#' | ||
#' This testthat file tests the handle-vaccine function | ||
test_that("handle vaccine correctly maps vaccine", { | ||
result <- sapply(c("percent with up to date hpv vaccination coverage, ages 13-15", | ||
"percent with up to date hpv vaccination coverage, ages 13-17"), | ||
handle_vaccine) | ||
expected <- c(`percent with up to date hpv vaccination coverage, ages 13-15` = "v281", | ||
`percent with up to date hpv vaccination coverage, ages 13-17` = "v282") | ||
|
||
expect_equal(result, expected) | ||
}) | ||
|
||
test_that("handle vaccine expects errors for incorrect arguments", { | ||
expect_error(handle_vaccine("carrot")) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#' Test Handle Women's Health | ||
#' | ||
#' This testthat file tests the handle-whealth function | ||
test_that("handle whealth correctly maps whealth", { | ||
result <- sapply(c("mammogram in past 2 years, ages 50-74", | ||
"mammogram in past 2 years, ages 40+", | ||
"pap smear in past 3 years, no hysterectomy, ages 21-65"), | ||
handle_whealth) | ||
expected <- c(`mammogram in past 2 years, ages 50-74` = "v05", | ||
`mammogram in past 2 years, ages 40+` = "v06", | ||
`pap smear in past 3 years, no hysterectomy, ages 21-65` = "v17") | ||
|
||
expect_equal(result, expected) | ||
}) | ||
|
||
test_that("handle whealth expects errors for incorrect arguments", { | ||
expect_error(handle_whealth("carrot")) | ||
}) |
Oops, something went wrong.