Skip to content

Commit

Permalink
update unit test per the arg position change
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosemary Li committed Feb 19, 2024
1 parent 64dcdb1 commit 7c91722
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tests/testthat/test-calculate_study_day.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ test_that("`calculate_study_day()` works as expected for invalid input", {
"dm_domain is not a data frame"
)
expect_error(
calculate_study_day(iris, iris, "c", "d", "e"),
calculate_study_day(iris, "d", "e", "iris", "b"),
"dm_domain needs to have the variable of refdt"
)
expect_error(
calculate_study_day(iris, iris, "Species", "d", "e"),
calculate_study_day(iris, "e", "d", "iris", "Species"),
"sdtm_in needs to have the variable of tgdt"
)
expect_error(
calculate_study_day(iris, iris, "Species", "Petal.Length", "e"),
calculate_study_day(iris, "Petal.Length", "e", "iris", "Species"),
"needs to have the variable of merge_key"
)
expect_error(
calculate_study_day(iris, iris, "Species", "Petal.Length", 123L, "Species"),
calculate_study_day(iris, "Petal.Length", 123L, "iris", "Species", "Species"),
"study_day_var is not a character vector"
)
expect_warning(
calculate_study_day(ae, dm, "RFSTDTC", "AESTDTC", "AENDY"),
calculate_study_day(ae, "AESTDTC", "AENDY", "dm", "RFSTDTC"),
"Target date and the returned study day doesn't match."
)

Expand All @@ -45,7 +45,7 @@ test_that("`calculate_study_day()` works as expected for invalid input", {
stringsAsFactors = FALSE
)
expect_warning(
calculate_study_day(ae, dm1, "RFSTDTC", "AESTDTC", "AESTDY"),
calculate_study_day(ae, "AESTDTC", "AESTDY", "dm1", "RFSTDTC"),
"Reference date is not unique for each patient!"
)

Expand All @@ -55,13 +55,13 @@ test_that("`calculate_study_day()` works as expected for invalid input", {
stringsAsFactors = FALSE
)
expect_warning(
calculate_study_day(ae, dm2, "RFSTDTC", "AESTDTC", "AESTDY"),
calculate_study_day(ae, "AESTDTC", "AESTDY", "dm2", "RFSTDTC"),
"Encountered errors when converting refdt to dates."
)
})

test_that("`calculate_study_day()` works as expected for valid input", {
res <- calculate_study_day(ae, dm, "RFSTDTC", "AESTDTC", "AESTDY")
res <- calculate_study_day(ae, "AESTDTC", "AESTDY", "dm", "RFSTDTC")
expected <- c(-31L, 1L, NA)
expect_equal(res$AESTDY, expected, tolerance = "1.5e-08")
})

0 comments on commit 7c91722

Please sign in to comment.