Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shajoezhu committed Nov 13, 2024
1 parent c04aff0 commit 03d6a79
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 64 deletions.
2 changes: 1 addition & 1 deletion R/t_dm_slide.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#'
t_dm_slide <- function(adsl,
arm = "TRT01P",
vars = c("AGEGR1", "SEX", "RACE", "BECOG", "BBMI"),
vars = c("AGE", "SEX", "RACE"),
stats = c("median", "range", "count_fraction"),
split_by_study = FALSE,
side_by_side = NULL) {
Expand Down
13 changes: 0 additions & 13 deletions R/util.R
Original file line number Diff line number Diff line change
Expand Up @@ -669,19 +669,6 @@ lyt_to_side_by_side_two_data <- function(lyt, anl, alt_counts_df, side_by_side =
return(result)
}

#' Checker of data frame display per patient (or not)
#'
#' @param pp per patient
#' @param colname name of column
if_display_pp <- function(pp, colname = FALSE) {
if (!pp) {
if (!colname) {
return("USUBJID")
}
return("Patient ID")
}
return(NULL)
}

do_call <- function(fun, ...) {
args <- list(...)
Expand Down
16 changes: 0 additions & 16 deletions man/if_display_pp.Rd

This file was deleted.

2 changes: 1 addition & 1 deletion man/t_dm_slide.Rd

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

66 changes: 33 additions & 33 deletions tests/testthat/test-save_output.R
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
test_that("save an output", {
output <- t_ds_slide(adsl = testdata$adsl) %>% decorate(title = "test title", footnote = "")
output <- t_dm_slide(adsl = testdata$adsl) %>% decorate(title = "test title", footnote = "")
testthat::expect_no_error(
save_output(
output,
file_name = "t_ds_output",
file_name = "t_dm_output",
save_rds = TRUE
)
)
})


test_that("Test save_output (Save an Output)", {
library(dplyr)
adsl <- eg_adsl %>%
mutate(TRT01A = factor(TRT01A, levels = c("A: Drug X", "B: Placebo")))
adae <- eg_adae %>%
mutate(TRT01A = factor(TRT01A, levels = c("A: Drug X", "B: Placebo")))
adae$ATOXGR <- adae$AETOXGR
output_dir <- tempdir()
# test_that("Test save_output (Save an Output)", {
# library(dplyr)
# adsl <- eg_adsl %>%
# mutate(TRT01A = factor(TRT01A, levels = c("A: Drug X", "B: Placebo")))
# adae <- eg_adae %>%
# mutate(TRT01A = factor(TRT01A, levels = c("A: Drug X", "B: Placebo")))
# adae$ATOXGR <- adae$AETOXGR
# output_dir <- tempdir()
#
# expect_snapshot(print(t_ae_pt_slide(adsl, adae, "TRT01A", 2) %>%
# decorate(
# title = "Serious Adverse Events, Safety-Evaluable Patients",
# footnote = "",
# paper = "P8",
# for_test = TRUE
# ) %>%
# save_output(
# file_name = file.path(output_dir, "t_ae_SER_SE"),
# save_rds = TRUE
# )))
# })

expect_snapshot(print(t_ae_pt_slide(adsl, adae, "TRT01A", 2) %>%
decorate(
title = "Serious Adverse Events, Safety-Evaluable Patients",
footnote = "",
paper = "P8",
for_test = TRUE
) %>%
save_output(
file_name = file.path(output_dir, "t_ae_SER_SE"),
save_rds = TRUE
)))
})

test_that("save an output", {
output <- t_ds_slide(adsl = testdata$adsl) %>% decorate(title = "test title", footnote = "")
testthat::expect_no_error(
save_output(
output,
file_name = "t_ds_output",
save_rds = TRUE
)
)
})
# test_that("save an output", {
# output <- t_ds_slide(adsl = testdata$adsl) %>% decorate(title = "test title", footnote = "")
# testthat::expect_no_error(
# save_output(
# output,
# file_name = "t_ds_output",
# save_rds = TRUE
# )
# )
# })

0 comments on commit 03d6a79

Please sign in to comment.