Skip to content

Commit

Permalink
trim tests on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Liming Li (李黎明) committed Oct 9, 2024
1 parent fa107b4 commit fe9af7c
Show file tree
Hide file tree
Showing 21 changed files with 55 additions and 706 deletions.
704 changes: 0 additions & 704 deletions tests/testthat/_snaps/vst01.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions tests/testthat/test-ael01_nollt.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# ael01_nollt ----

test_that("ael01_nollt works with admh dataset", {
skip_on_os("windows")
res <- expect_silent(
run(ael01_nollt, syn_data, dataset = "admh", key_cols = c("MHBODSYS", "MHDECOD"), disp_cols = "MHTERM")
)
Expand Down Expand Up @@ -64,6 +65,7 @@ test_that("ael01_nollt listing can be split by an additional variable", {
})

test_that("split ael01_nollt listing do not display missing values", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$admh <- proc_data$admh[proc_data$admh$SEX == "F", ]

Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-ael02.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# ael02 ----

test_that("ael02 works with adae dataset", {
skip_on_os("windows")
res <- expect_silent(
run(ael02, syn_data, dataset = "adae")
)
Expand All @@ -27,6 +28,7 @@ test_that("ael02 can handle all missing values", {


test_that("ael02 functions work as expected", {
skip_on_os("windows")
res <- expect_silent(
ael02_pre(syn_data) %>%
ael02_main()
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-ael03.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# ael03 ----

test_that("ael03 works with adae dataset", {
skip_on_os("windows")
res <- expect_silent(
run(ael03, syn_data, dataset = "adae")
)
Expand All @@ -27,6 +28,7 @@ test_that("ael03 can handle all missing values", {
# ael03 functions ----

test_that("ael03 functions work as expected", {
skip_on_os("windows")
res <- expect_silent(
ael03_pre(syn_data) %>%
ael03_main()
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-aet01.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ test_that("aet01 can handle all NA values", {
})

test_that("aet01 can handle some NA values", {
skip_on_os("windows")
new_aesdth <- c(NA, "", as.character(syn_data$adae$AESDTH[-c(1, 2)]))
new_aeser <- c(NA, "", as.character(syn_data$adae$AESER[-c(1, 2)]))

Expand All @@ -30,6 +31,7 @@ test_that("aet01 can handle some NA values", {
})

test_that("aet01 can use custom anl_vars", {
skip_on_os("windows")
proc_data <- syn_data
res <- expect_silent(run(aet01, proc_data, anl_vars = list(safety_var = "FATAL")))
expect_snapshot(cat(export_as_txt(res, lpp = 100)))
Expand All @@ -48,6 +50,7 @@ test_that("aet01 fails on incomplete data input", {
})

test_that("aet01 can use custom medconcept_var", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$adae$SMQ01 <- with_label(proc_data$adae$SMQ01NAM != "", "SMQ 01")
res <- expect_silent(
Expand All @@ -66,6 +69,7 @@ test_that("aet01 can use custom medconcept_var", {
})

test_that("aet01 can conditionally show the number of withdrawal", {
skip_on_os("windows")
expect_silent(res <- run(aet01, syn_data, arm_var = "ARM", show_wd = FALSE))
expect_snapshot(cat(export_as_txt(res, lpp = 100)))
})
2 changes: 2 additions & 0 deletions tests/testthat/test-aet01_aesi.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# aet01_aesi ----

test_that("aet01_aesi can handle all NA values", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$adae <- proc_data$adae %>%
mutate(
Expand All @@ -20,6 +21,7 @@ test_that("aet01_aesi can handle all NA values", {
})

test_that("aet01_aesi can handle some NA values", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$adae <- proc_data$adae %>%
mutate(
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-aet02.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ test_that("aet02 handle empty data input", {
})

test_that("aet02 can have different levels of row_split", {
skip_on_os("windows")
res1 <- run(aet02, syn_data, row_split_var = NULL)
res2 <- run(aet02, syn_data, row_split_var = c("AEBODSYS", "AEDECOD"))
expect_snapshot(cat(export_as_txt(res1, lpp = 100)))
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-aet03.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
test_that("aet03 can handle NA values", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$adae <- proc_data$adae %>%
mutate(
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-aet04.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ test_that("aet04 can handle NA values", {
})

test_that("aet04 can handle some NA values", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$adae[1:2, c("AEBODSYS", "AEDECOD")] <- NA
res1 <- expect_silent(run(aet04, proc_data))
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-cfbt01.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ test_that("cfbt01 functions with default argument value return expected result w
# cfbt01 ----

test_that("cfbt01 can handle n = 0 and outputs NE instead of infs and NAs", {
skip_on_os("windows")
proc_data <- dunlin::log_filter(
syn_data,
PARAMCD %in% c("DIABP", "SYSBP"), "advs"
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-chevron_tlg-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ syn_adv <- syn_data[c("adsl", "adae")]
syn_adv$adae <- syn_adv$adae[syn_adv$adae$AEBODSYS %in% c("cl A.1", "cl B.1", "cl B.2"), ]

test_that("run works as expected for chevron_t object", {
skip_on_os("windows")
res <- run(aet04, syn_adv, prune_0 = TRUE)
expect_snapshot(cat(export_as_txt(res, lpp = 100)))
})
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-egt01.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# egt01 functions ----

test_that("egt01 functions with default argument value return expected result with test data", {
skip_on_os("windows")
pre_data <- egt01_pre(syn_data)
raw_res <- egt01_main(pre_data)
res <- cfbt01_post(raw_res)
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-ext01.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# ext01 functions ----

test_that("ext01 functions with default argument value return expected result with test data", {
skip_on_os("windows")
pre_data <- ext01_pre(syn_data)
raw_res <- ext01_main(pre_data)
res <- ext01_post(raw_res)
Expand All @@ -18,6 +19,7 @@ test_that("ext01 functions with categorical data return expected result with tes
# ext01 ----

test_that("ext01 works", {
skip_on_os("windows")
proc_data <- syn_data
res1 <- expect_silent(run(ext01, proc_data))
expect_snapshot(cat(export_as_txt(res1, lpp = 100)))
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-fstg01.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ test_that("fstg01 works as expected", {
# fstg01 ----

test_that("fstg01 works as expected with custom color set", {
skip_on_os("windows")
proc_data <- dunlin::log_filter(syn_data, PARAMCD == "BESRSPI" & ARM %in% c("A: Drug X", "B: Placebo"), "adrs")

res1 <- expect_silent(run(fstg01, proc_data, response = c("CR", "PR"), dataset = "adrs", col = "gray"))
Expand All @@ -20,6 +21,7 @@ test_that("fstg01 works as expected with custom color set", {
})

test_that("fstg01 works if changes are in subgroups, conf_level, and label_all", {
skip_on_os("windows")
proc_data <- dunlin::log_filter(syn_data, PARAMCD == "BESRSPI" & ARM %in% c("A: Drug X", "B: Placebo"), "adrs")

res1 <- expect_silent(run(fstg01, proc_data, response = c("CR", "PR"), subgroups = NULL, dataset = "adrs"))
Expand All @@ -33,6 +35,7 @@ test_that("fstg01 works if changes are in subgroups, conf_level, and label_all",
})

test_that("fstg01 can handle some NA values in subgroups", {
skip_on_os("windows")
proc_data <- dunlin::log_filter(syn_data, PARAMCD == "BESRSPI" & ARM %in% c("A: Drug X", "B: Placebo"), "adrs")
proc_data$adrs[1:2, "SEX"] <- NA
proc_data$adrs[3:4, "AGEGR1"] <- NA
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-fstg02.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ test_that("fstg02 works as expected", {
# fstg02 ----

test_that("fstg02 works as expected with custom color set", {
skip_on_os("windows")
proc_data <- dunlin::log_filter(syn_data, PARAMCD == "OS" & ARM %in% c("A: Drug X", "B: Placebo"), "adtte")

res1 <- expect_silent(run(fstg02, proc_data, dataset = "adtte", col = "gray"))
Expand All @@ -20,6 +21,7 @@ test_that("fstg02 works as expected with custom color set", {
})

test_that("fstg02 works if changes are in subgroups, strata_var, conf_level, and label_all", {
skip_on_os("windows")
proc_data <- dunlin::log_filter(syn_data, PARAMCD == "OS" & ARM %in% c("A: Drug X", "B: Placebo"), "adtte")

res1 <- expect_silent(run(fstg02, proc_data, subgroups = NULL, dataset = "adtte"))
Expand All @@ -33,6 +35,7 @@ test_that("fstg02 works if changes are in subgroups, strata_var, conf_level, and
})

test_that("fstg02 can handle some NA values in subgroups", {
skip_on_os("windows")
proc_data <- dunlin::log_filter(syn_data, PARAMCD == "OS" & ARM %in% c("A: Drug X", "B: Placebo"), "adtte")
proc_data$adtte[1:2, "SEX"] <- NA
proc_data$adtte[3:4, "AGEGR1"] <- NA
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-lbt01.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# lbt01 functions ----

test_that("lbt01 functions with default argument value return expected result with test data", {
skip_on_os("windows")
pre_data <- lbt01_pre(syn_data)
raw_res <- lbt01_main(pre_data)
res <- cfbt01_post(raw_res)
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-lbt14.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ test_that("lbt14 functions with default argument value return expected result wi
})

test_that("lbt14 functions with default argument value return expected result with test data when direction = high", {
skip_on_os("windows")
pre_data <- lbt14_pre(syn_lab, direction = "high")
raw_res <- lbt14_main(pre_data, direction = "high")
res <- lbt14_post(raw_res, direction = "high")
expect_snapshot(cat(export_as_txt(res, lpp = 100)))
})

test_that("lbt14 functions with `gr_missing = excl` return expected result with test data", {
skip_on_os("windows")
pre_data <- lbt14_pre(syn_lab, gr_missing = "excl")
raw_res <- lbt14_main(pre_data)
res <- lbt14_post(raw_res)
Expand All @@ -34,6 +36,7 @@ test_that("lbt14 functions with `gr_missing = gr_0` return expected result with

# lbt14 ----
test_that("lbt14 can handle all NA values", {
skip_on_os("windows")
proc_data <- syn_lab
proc_data$adlb <- proc_data$adlb %>%
mutate(
Expand Down Expand Up @@ -65,6 +68,7 @@ test_that("lbt14 can handle some NA values", {
})

test_that("lbt14 can accept different gr_missing", {
skip_on_os("windows")
res1 <- run(lbt14, syn_lab, gr_missing = "incl")
res2 <- run(lbt14, syn_lab, gr_missing = "excl")
res3 <- run(lbt14, syn_lab, gr_missing = "gr_0")
Expand Down Expand Up @@ -97,6 +101,7 @@ test_that("lbt14 can handle all NA values with direction = high", {
})

test_that("lbt14 can handle some NA values with direction = high", {
skip_on_os("windows")
set.seed(1)
new_btoxgr <- syn_lab$adlb$BTOXGR
new_btoxgr[sample(seq_along(new_btoxgr), 20)] <- NA
Expand All @@ -116,6 +121,7 @@ test_that("lbt14 can handle some NA values with direction = high", {
})

test_that("lbt14 can accept different gr_missing with direction = high", {
skip_on_os("windows")
proc_data <- syn_lab
res1 <- run(lbt14, proc_data, gr_missing = "incl", direction = "high")
res2 <- run(lbt14, proc_data, gr_missing = "excl", direction = "high")
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-lbt15.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ test_that("lbt15 functions with default argument value return expected result wi
# lbt15 ----

test_that("lbt15 can handle all NA values", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$adlb <- proc_data$adlb %>%
mutate(
Expand All @@ -32,6 +33,7 @@ test_that("lbt15 can handle missing levels", {
})

test_that("lbt15 can handle missing levels in baseline", {
skip_on_os("windows")
proc_data <- syn_data
proc_data$adlb <- proc_data$adlb %>%
mutate(
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-mng01.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ test_that("mng01 works as expected with default argument values", {
})

test_that("mng01 works as expected with custom argument values", {
skip_on_os("windows")
withr::with_options(opts_partial_match_old, {
col <- c(
"B: Placebo" = "black",
Expand Down Expand Up @@ -50,6 +51,7 @@ test_that("mng01 works as expected with custom argument values", {
# mng01 ----

test_that("mng01 works as expected with custom color set", {
skip_on_os("windows")
withr::with_options(opts_partial_match_old, {
col <- c(
"B: Placebo" = "black",
Expand All @@ -71,6 +73,7 @@ test_that("mng01 works as expected with custom color set", {
})

test_that("mng01 works as expected with custom line type set", {
skip_on_os("windows")
withr::with_options(opts_partial_match_old, {
lty <- c(
"B: Placebo" = "99",
Expand Down Expand Up @@ -103,6 +106,7 @@ test_that("mng01 works with table = NULL", {
})

test_that("mng01 works with combination of x variables", {
skip_on_os("windows")
withr::with_options(opts_partial_match_old, {
proc_data <- syn_data
res <- run(
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-rspt01.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ test_that("rspt01 works as expected", {
})

test_that("rspt01 works as expected for stratified and unstratified analysis", {
skip_on_os("windows")
filter_data <- dunlin::log_filter(syn_data, PARAMCD == "BESRSPI", "adrs")
res <- expect_silent(run(rspt01, filter_data,
dataset = "adrs",
Expand All @@ -26,6 +27,7 @@ test_that("rspt01 works as expected for stratified and unstratified analysis", {
})

test_that("rspt01 works as expected for unstratified analysis only", {
skip_on_os("windows")
filter_data <- dunlin::log_filter(syn_data, PARAMCD == "BESRSPI", "adrs")
res <- expect_silent(run(rspt01, filter_data,
dataset = "adrs",
Expand All @@ -44,6 +46,7 @@ test_that("rspt01 works as expected for unstratified analysis only", {
})

test_that("rspt01 works as expected for stratified analysis only", {
skip_on_os("windows")
filter_data <- dunlin::log_filter(syn_data, PARAMCD == "BESRSPI", "adrs")
res <- expect_silent(run(rspt01, filter_data,
dataset = "adrs",
Expand Down Expand Up @@ -84,6 +87,7 @@ test_that("rspt01 works if change reference group", {
})

test_that("rspt01 works if change statistic methods", {
skip_on_os("windows")
filter_data <- dunlin::log_filter(syn_data, PARAMCD == "BESRSPI", "adrs")
res <- expect_silent(run(rspt01, filter_data,
dataset = "adrs",
Expand Down Expand Up @@ -113,6 +117,7 @@ test_that("rspt01 works if change statistic methods", {


test_that("rspt01 works if change confidence interval", {
skip_on_os("windows")
filter_data <- dunlin::log_filter(syn_data, PARAMCD == "BESRSPI", "adrs")
res <- expect_silent(run(rspt01, filter_data,
dataset = "adrs",
Expand Down
13 changes: 11 additions & 2 deletions tests/testthat/test-vst01.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# vst12 functions ----

test_that("vst01 functions with default argument value return expected result with test data", {
pre_data <- vst01_pre(syn_data)
proc_data <- dunlin::log_filter(
syn_data,
PARAMCD %in% c("DIABP", "SYSBP"), "advs"
)
pre_data <- vst01_pre(proc_data)
raw_res <- vst01_main(pre_data)
res <- cfbt01_post(raw_res)
expect_snapshot(cat(export_as_txt(res, lpp = 200)))
Expand All @@ -10,6 +14,11 @@ test_that("vst01 functions with default argument value return expected result wi
# vst01 ----

test_that("run vst01 works as expected", {
res <- expect_silent(run(vst01, syn_data))
skip_on_os("windows")
proc_data <- dunlin::log_filter(
syn_data,
PARAMCD %in% c("DIABP", "SYSBP"), "advs"
)
res <- expect_silent(run(vst01, proc_data))
expect_snapshot(cat(export_as_txt(res, lpp = 200)))
})

0 comments on commit fe9af7c

Please sign in to comment.