Skip to content

Commit

Permalink
update df name for lint compliance
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosemary Li committed Feb 11, 2024
1 parent c3ec9ce commit 01c3fc5
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
@@ -1,8 +1,8 @@
AE <- data.frame(
ae <- data.frame(
USUBJID = c("study123-123", "study123-124", "study123-125"),
AESTDTC = c("2012-01-01", "2012-04-14", "2012-04-14")
)
DM <- data.frame(
dm <- data.frame(
USUBJID = c("study123-123", "study123-124", "study123-125"),
RFSTDTC = c("2012-02-01", "2012-04-14", NA_character_)
)
Expand Down Expand Up @@ -33,31 +33,31 @@ test_that("`calculate_study_day()` works as expected for invalid input", {
"study_day_var is not a character vector"
)
expect_warning(
calculate_study_day(AE, DM, "RFSTDTC", "AESTDTC", "AENDY"),
calculate_study_day(ae, dm, "RFSTDTC", "AESTDTC", "AENDY"),
"Target date and the returned study day doesn't match."
)

DM1 <- data.frame(
dm1 <- data.frame(
USUBJID = c("study123-123", "study123-123", "study123-125"),
RFSTDTC = c("2012-02-01", "2012-04-14", "2012-04-14")
)
expect_warning(
calculate_study_day(AE, DM1, "RFSTDTC", "AESTDTC", "AESTDY"),
calculate_study_day(ae, dm1, "RFSTDTC", "AESTDTC", "AESTDY"),
"Reference date is not unique for each patient!"
)

DM2 <- data.frame(
dm2 <- data.frame(
USUBJID = c("study123-123", "study123-124", "study123-125"),
RFSTDTC = c(123, 456, 789)
)
expect_warning(
calculate_study_day(AE, DM2, "RFSTDTC", "AESTDTC", "AESTDY"),
calculate_study_day(ae, dm2, "RFSTDTC", "AESTDTC", "AESTDY"),
"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, dm, "RFSTDTC", "AESTDTC", "AESTDY")
expected <- c(-31, 1, NA)
expect_equal(res$AESTDY, expected)
})

0 comments on commit 01c3fc5

Please sign in to comment.