Skip to content

Commit

Permalink
add tests for check functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ernestguevarra committed Jun 29, 2024
1 parent ab39bb0 commit 67c2e8b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/cod_structure_input.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#' record identifiers. Default to NULL. If NULL, unique record identifiers
#' will be generated.
#'
#' @returns A data.frame with 6 columns and number of rows equal to `df` with
#' @returns A tibble with 6 columns and number of rows equal to `df` with
#' names `"FreeId"`, `"Sex"`, `"Age Value"`, `"Age Type"`, `"Code"`, and
#' `"Death Date"`.
#'
Expand Down
2 changes: 1 addition & 1 deletion man/cod_structure.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/testthat/test-cod_check_input.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ testthat::test_that(
"code_check", "code_check_note",
"dod_check", "dod_check_note")
)

expect_warning(
cod_check_codedit_input(icd10_example |> dplyr::select(-FreeId))
)
})
19 changes: 19 additions & 0 deletions tests/testthat/test-cod_structure_input.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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"
)
)

0 comments on commit 67c2e8b

Please sign in to comment.