-
Notifications
You must be signed in to change notification settings - Fork 0
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 #87 from OxfordIHTM/dev
add tests for new functions
- Loading branch information
Showing
7 changed files
with
71 additions
and
4 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.
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,22 @@ | ||
# Tets for cod_check_dod ------------------------------------------------------- | ||
|
||
testthat::test_that( | ||
"cod_check_dod outputs appropriate results", { | ||
expect_s3_class(cod_check_dod("2024"), "tbl") | ||
|
||
expect_identical( | ||
cod_check_dod("2024"), | ||
tibble::tibble( | ||
dod_check = 0L, | ||
dod_check_note = "No issues with date of death value" | ||
) | ||
) | ||
|
||
expect_identical( | ||
cod_check_dod("2024-06-01"), | ||
tibble::tibble( | ||
dod_check = 1L, | ||
dod_check_note = "Date of death value is not in year format" | ||
) | ||
) | ||
}) |
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 @@ | ||
# Tests for cod_check_input ---------------------------------------------------- | ||
|
||
testthat::test_that( | ||
"cod_check_input outputs appropriate results", { | ||
expect_s3_class(cod_check_codedit_input(icd10_example), "tbl") | ||
|
||
expect_named( | ||
cod_check_codedit_input(icd10_example), | ||
c("sex_check", "sex_check_note", | ||
"age_check", "age_check_note", | ||
"code_check", "code_check_note", | ||
"dod_check", "dod_check_note") | ||
) | ||
|
||
expect_warning( | ||
cod_check_codedit_input(icd10_example |> dplyr::select(-FreeId)) | ||
) | ||
}) |
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,27 @@ | ||
# Tests for cod_structure_input ------------------------------------------------ | ||
|
||
df <- data.frame( | ||
id = 1:3, | ||
sex = c(1, 1, 2), | ||
dob = c("1977-11-05", "1971-04-04", "2012-08-13"), | ||
dod = c("2024-06-28", "2023-10-11", "2023-09-25"), | ||
code = c("P219", "O230", "Q913") | ||
) | ||
|
||
|
||
testthat::test_that( | ||
"cod_structure_input outputs appropriate results", { | ||
expect_s3_class( | ||
cod_structure_input( | ||
df, sex = "sex", dob = "dob", dod = "dod", code = "code" | ||
), | ||
"tbl" | ||
) | ||
|
||
expect_s3_class( | ||
cod_structure_input( | ||
df = df, sex = "sex", dob = "dob", dod = "dod", code = "code", id = "id" | ||
), | ||
"tbl" | ||
) | ||
}) |