diff --git a/R/ard_car_vif.R b/R/ard_car_vif.R index 66ad23728..8492dcaee 100644 --- a/R/ard_car_vif.R +++ b/R/ard_car_vif.R @@ -74,6 +74,7 @@ ard_car_vif <- function(x, ...) { ) |> dplyr::mutate( context = "car_vif", + stat = as.list(.data$stat), stat_label = ifelse( .data$stat_name == "aGVIF", "Adjusted GVIF", diff --git a/R/ard_regression.R b/R/ard_regression.R index 37ea9063b..a08f4688a 100644 --- a/R/ard_regression.R +++ b/R/ard_regression.R @@ -52,7 +52,7 @@ ard_regression.default <- function(x, tidy_fun = broom.helpers::tidy_with_broom_ if (!is.null(lst_results[["result"]])) { lst_results[["result"]] |> dplyr::mutate( - variable_level = dplyr::if_else(.data$var_type %in% "continuous", NA_character_, .data$label), + variable_level = as.list(dplyr::if_else(.data$var_type %in% "continuous", NA_character_, .data$label)), dplyr::across(-c("variable", "variable_level"), .fns = as.list) ) |> tidyr::pivot_longer( diff --git a/R/ard_stats_aov.R b/R/ard_stats_aov.R index 5af852644..285b51139 100644 --- a/R/ard_stats_aov.R +++ b/R/ard_stats_aov.R @@ -50,6 +50,16 @@ ard_stats_aov <- function(formula, data, ...) { TRUE ~ .data$stat_name ), context = "stats_aov", + fmt_fn = lapply( + .data$stat, + function(x) { + switch(is.integer(x), + 0L + ) %||% switch(is.numeric(x), + 1L + ) + } + ), warning = aov["warning"], error = aov["error"] ) |> diff --git a/tests/testthat/_snaps/ard_car_vif.md b/tests/testthat/_snaps/ard_car_vif.md index 4f3b5ac9d..f08df5af3 100644 --- a/tests/testthat/_snaps/ard_car_vif.md +++ b/tests/testthat/_snaps/ard_car_vif.md @@ -5,10 +5,10 @@ Output variable context stat_name stat_label stat fmt_fn warning error 1 ARM car_vif GVIF GVIF 1.015675 1 NULL NULL - 2 ARM car_vif df df 2.000000 1 NULL NULL + 2 ARM car_vif df df 2 1 NULL NULL 3 ARM car_vif aGVIF Adjusted GVIF 1.003896 1 NULL NULL 4 SEX car_vif GVIF GVIF 1.015675 1 NULL NULL - 5 SEX car_vif df df 1.000000 1 NULL NULL + 5 SEX car_vif df df 1 1 NULL NULL 6 SEX car_vif aGVIF Adjusted GVIF 1.007807 1 NULL NULL --- diff --git a/tests/testthat/_snaps/ard_regression.md b/tests/testthat/_snaps/ard_regression.md index cd57f0dbe..28439ecd7 100644 --- a/tests/testthat/_snaps/ard_regression.md +++ b/tests/testthat/_snaps/ard_regression.md @@ -59,12 +59,12 @@ cards::round5(x, 3), x))) Output variable variable_level stat_name stat warning error - 1 hp n_obs 32 NULL NULL - 2 hp estimate -0.03 NULL NULL - 3 hp std.error 0.015 NULL NULL - 4 hp statistic -2.088 NULL NULL - 5 hp conf.low -0.059 NULL NULL - 6 hp conf.high -0.002 NULL NULL + 1 hp NA n_obs 32 NULL NULL + 2 hp NA estimate -0.03 NULL NULL + 3 hp NA std.error 0.015 NULL NULL + 4 hp NA statistic -2.088 NULL NULL + 5 hp NA conf.low -0.059 NULL NULL + 6 hp NA conf.high -0.002 NULL NULL 7 cyl.sd__(Intercept) cyl.sd__(Intercept) estimate 4.023 NULL NULL 8 Residual.sd__Observation Residual.sd__Observation estimate 3.149 NULL NULL diff --git a/tests/testthat/_snaps/ard_stats_aov.md b/tests/testthat/_snaps/ard_stats_aov.md index 3ae9ebce4..5af7e5b53 100644 --- a/tests/testthat/_snaps/ard_stats_aov.md +++ b/tests/testthat/_snaps/ard_stats_aov.md @@ -3,15 +3,26 @@ Code as.data.frame(ard_stats_aov(AGE ~ ARM + SEX, data = cards::ADSL)) Output - variable context stat_name stat_label stat warning error - 1 ARM stats_aov sumsq Sum of Squares 71.38574 NULL NULL - 2 ARM stats_aov df Degrees of Freedom 2 NULL NULL - 3 ARM stats_aov meansq Mean of Sum of Squares 35.69287 NULL NULL - 4 ARM stats_aov statistic Statistic 0.5235002 NULL NULL - 5 ARM stats_aov p.value p-value 0.5930912 NULL NULL - 6 SEX stats_aov sumsq Sum of Squares 87.40947 NULL NULL - 7 SEX stats_aov df Degrees of Freedom 1 NULL NULL - 8 SEX stats_aov meansq Mean of Sum of Squares 87.40947 NULL NULL - 9 SEX stats_aov statistic Statistic 1.282017 NULL NULL - 10 SEX stats_aov p.value p-value 0.2586091 NULL NULL + variable context stat_name stat_label stat fmt_fn warning + 1 ARM stats_aov sumsq Sum of Squares 71.38574 1 NULL + 2 ARM stats_aov df Degrees of Freedom 2 1 NULL + 3 ARM stats_aov meansq Mean of Sum of Squares 35.69287 1 NULL + 4 ARM stats_aov statistic Statistic 0.5235002 1 NULL + 5 ARM stats_aov p.value p-value 0.5930912 1 NULL + 6 SEX stats_aov sumsq Sum of Squares 87.40947 1 NULL + 7 SEX stats_aov df Degrees of Freedom 1 1 NULL + 8 SEX stats_aov meansq Mean of Sum of Squares 87.40947 1 NULL + 9 SEX stats_aov statistic Statistic 1.282017 1 NULL + 10 SEX stats_aov p.value p-value 0.2586091 1 NULL + error + 1 NULL + 2 NULL + 3 NULL + 4 NULL + 5 NULL + 6 NULL + 7 NULL + 8 NULL + 9 NULL + 10 NULL diff --git a/tests/testthat/test-ard_aod_wald_test.R b/tests/testthat/test-ard_aod_wald_test.R index 3576c62bc..58907cd82 100644 --- a/tests/testthat/test-ard_aod_wald_test.R +++ b/tests/testthat/test-ard_aod_wald_test.R @@ -18,3 +18,11 @@ test_that("ard_aod_wald_test() works", { dplyr::select(c(context, error)) ) }) + +test_that("ard_aod_wald_test() follows ard structure", { + expect_silent( + suppressWarnings(lm(AGE ~ ARM, data = cards::ADSL)) |> + ard_aod_wald_test() |> + cards::check_ard_structure(method = FALSE) + ) +}) diff --git a/tests/testthat/test-ard_car_anova.R b/tests/testthat/test-ard_car_anova.R index d1d45b629..3c61061f2 100644 --- a/tests/testthat/test-ard_car_anova.R +++ b/tests/testthat/test-ard_car_anova.R @@ -20,3 +20,11 @@ test_that("ard_car_anova() messaging", { ard_car_anova(mtcars) ) }) + +test_that("ard_car_anova() follows ard structure", { + expect_silent( + suppressWarnings(glm(vs ~ factor(cyl) + factor(am), data = mtcars, family = binomial)) |> + ard_car_anova(test.statistic = "Wald") |> + cards::check_ard_structure(method = FALSE) + ) +}) diff --git a/tests/testthat/test-ard_car_vif.R b/tests/testthat/test-ard_car_vif.R index 34ea2df7b..2220b284e 100644 --- a/tests/testthat/test-ard_car_vif.R +++ b/tests/testthat/test-ard_car_vif.R @@ -31,3 +31,11 @@ test_that("ard_vif() issues friendly messaging for incorrect object passed in/ca cards::ADSL |> ard_car_vif() ) }) + +test_that("ard_car_vif() follows ard structure", { + expect_silent( + lm(AGE ~ ARM + SEX, data = cards::ADSL) |> + ard_car_vif() |> + cards::check_ard_structure(method = FALSE) + ) +}) diff --git a/tests/testthat/test-ard_categorical.survey.design.R b/tests/testthat/test-ard_categorical.survey.design.R index dbc680d61..52e54981b 100644 --- a/tests/testthat/test-ard_categorical.survey.design.R +++ b/tests/testthat/test-ard_categorical.survey.design.R @@ -1309,3 +1309,18 @@ test_that("ard_categorical.survey.design(statistic) properly excluded unweighted dplyr::select(variable, variable_level, stat_name, stat_label, stat) ) }) + +test_that("ard_categorical follows ard structure", { + data(api, package = "survey") + svy_titanic <- survey::svydesign(~1, data = as.data.frame(Titanic), weights = ~Freq) + + expect_silent( + ard_categorical( + svy_titanic, + variables = c(Class, Age), + by = Survived, + denominator = "row" + ) |> + cards::check_ard_structure(method = FALSE) + ) +}) diff --git a/tests/testthat/test-ard_categorical_ci.survey.design.R b/tests/testthat/test-ard_categorical_ci.survey.design.R index a1a0d8da0..f1829aa3d 100644 --- a/tests/testthat/test-ard_categorical_ci.survey.design.R +++ b/tests/testthat/test-ard_categorical_ci.survey.design.R @@ -111,3 +111,10 @@ test_that("ard_categorical_ci(method)", { set_names(c("estimate", "conf.low", "conf.high")) ) }) + +test_that("ard_categorical_ci.survey.design() follows ard structure", { + expect_silent( + ard_categorical_ci(dclus1, variables = c(both, awards), method = "likelihood") |> + cards::check_ard_structure(method = TRUE) + ) +}) diff --git a/tests/testthat/test-ard_continuous.survey.design.R b/tests/testthat/test-ard_continuous.survey.design.R index 06b72d2ff..110deebb6 100644 --- a/tests/testthat/test-ard_continuous.survey.design.R +++ b/tests/testthat/test-ard_continuous.survey.design.R @@ -508,3 +508,13 @@ test_that("ard_continuous.survey.design() works when using generic names ", { ard_continuous(dclus2, variables = c(deff, mean.std.error), by = min) |> dplyr::select(stat) ) }) + +test_that("ard_continuous.survey.design() follows ard structure", { + data(api, package = "survey") + dclus1 <- survey::svydesign(id = ~dnum, weights = ~pw, data = apiclus1, fpc = ~fpc) + + expect_silent( + ard_continuous(dclus1, variables = c(cds, stype), by = snum) |> + cards::check_ard_structure(method = FALSE) + ) +}) diff --git a/tests/testthat/test-ard_continuous_ci.data.frame.R b/tests/testthat/test-ard_continuous_ci.data.frame.R index 824cc284a..13f111ec0 100644 --- a/tests/testthat/test-ard_continuous_ci.data.frame.R +++ b/tests/testthat/test-ard_continuous_ci.data.frame.R @@ -33,3 +33,14 @@ test_that("ard_continuous_ci.data.frame(method = 'wilcox.test')", { dplyr::select(-context) ) }) + +test_that("ard_continuous_ci.data.frame() follows ard structure", { + expect_silent( + ard_continuous_ci( + mtcars, + variables = mpg, + method = "wilcox.test" + ) |> + cards::check_ard_structure() + ) +}) diff --git a/tests/testthat/test-ard_continuous_ci.survey.design.R b/tests/testthat/test-ard_continuous_ci.survey.design.R index 4d1b76fc3..1202538fe 100644 --- a/tests/testthat/test-ard_continuous_ci.survey.design.R +++ b/tests/testthat/test-ard_continuous_ci.survey.design.R @@ -195,3 +195,10 @@ test_that("ard_continuous_ci() errors are captured", { ard_continuous_ci(dclus1, variables = sch.wide, method = "svymedian.beta") ) }) + +test_that("ard_continuous_ci.survey.design() follows ard structure", { + expect_silent( + ard_continuous_ci(dclus1, variables = c(api00, api99), df = 50) |> + cards::check_ard_structure(method = FALSE) + ) +}) diff --git a/tests/testthat/test-ard_dichotomous.survey.design.R b/tests/testthat/test-ard_dichotomous.survey.design.R index 1fdc49ebc..0690dc6b3 100644 --- a/tests/testthat/test-ard_dichotomous.survey.design.R +++ b/tests/testthat/test-ard_dichotomous.survey.design.R @@ -448,3 +448,19 @@ test_that("ard_dichotomous.survey.design() returns an error with erroneous input error = TRUE ) }) + + +test_that("ard_dichotomous.survey.design() follows ard structure", { + svy_dicho <- survey::svydesign(ids = ~1, data = mtcars, weights = ~1) + svy_dicho$variables <- svy_dicho$variables |> + dplyr::mutate(across(c("cyl", "am", "vs"), as.factor)) + expect_silent( + ard_dichotomous(svy_dicho, + by = vs, + variables = c(cyl, am), + value = list(cyl = 4), + denominator = "row" + ) |> + cards::check_ard_structure(method = FALSE) + ) +}) diff --git a/tests/testthat/test-ard_effectsize_cohens_d.R b/tests/testthat/test-ard_effectsize_cohens_d.R index cf846afe0..e1b826fb8 100644 --- a/tests/testthat/test-ard_effectsize_cohens_d.R +++ b/tests/testthat/test-ard_effectsize_cohens_d.R @@ -95,3 +95,26 @@ test_that("ard_effectsize_paired_cohens_d() works", { FALSE ) }) + +test_that("ard_effectsize_cohens_d() follows ard structure", { + expect_silent( + cards::ADSL |> + dplyr::filter(ARM %in% c("Placebo", "Xanomeline High Dose")) |> + ard_effectsize_cohens_d(by = ARM, variables = AGE, pooled_sd = FALSE) |> + cards::check_ard_structure() + ) + + # paired + ADSL_paired <- + cards::ADSL[c("ARM", "AGE")] |> + dplyr::filter(ARM %in% c("Placebo", "Xanomeline High Dose")) |> + dplyr::mutate(.by = ARM, USUBJID = dplyr::row_number()) |> + dplyr::group_by(USUBJID) |> + dplyr::filter(dplyr::n() > 1) + + expect_silent( + ADSL_paired |> + ard_effectsize_paired_cohens_d(by = ARM, variable = AGE, id = USUBJID) |> + cards::check_ard_structure() + ) +}) diff --git a/tests/testthat/test-ard_effectsize_hedges_g.R b/tests/testthat/test-ard_effectsize_hedges_g.R index b21748c60..c908ddb21 100644 --- a/tests/testthat/test-ard_effectsize_hedges_g.R +++ b/tests/testthat/test-ard_effectsize_hedges_g.R @@ -91,3 +91,26 @@ test_that("ard_effectsize_paired_hedges_g() works", { FALSE ) }) + +test_that("ard_effectsize_cohens_d() follows ard structure", { + expect_silent( + cards::ADSL |> + dplyr::filter(ARM %in% c("Placebo", "Xanomeline High Dose")) |> + ard_effectsize_hedges_g(by = ARM, variables = AGE, pooled_sd = FALSE) |> + cards::check_ard_structure(method = FALSE) + ) + + # paired + ADSL_paired <- + cards::ADSL[c("ARM", "AGE")] |> + dplyr::filter(ARM %in% c("Placebo", "Xanomeline High Dose")) |> + dplyr::mutate(.by = ARM, USUBJID = dplyr::row_number()) |> + dplyr::group_by(USUBJID) |> + dplyr::filter(dplyr::n() > 1) + + expect_silent( + ADSL_paired |> + ard_effectsize_paired_hedges_g(by = ARM, variable = AGE, id = USUBJID) |> + cards::check_ard_structure(method = FALSE) + ) +}) diff --git a/tests/testthat/test-ard_emmeans_mean_difference.R b/tests/testthat/test-ard_emmeans_mean_difference.R index c140c5b8b..81b07a77f 100644 --- a/tests/testthat/test-ard_emmeans_mean_difference.R +++ b/tests/testthat/test-ard_emmeans_mean_difference.R @@ -84,3 +84,16 @@ test_that("ard_emmeans_mean_difference() works", { getElement("estimate") ) }) + +test_that("ard_emmeans_mean_difference() follows ard structure", { + expect_silent( + ard_emmeans_mean_difference( + data = mtcars, + formula = vs ~ am + mpg, + method = "glm", + method.args = list(family = binomial), + response_type = "dichotomous" + ) |> + cards::check_ard_structure() + ) +}) diff --git a/tests/testthat/test-ard_missing.survey.design.R b/tests/testthat/test-ard_missing.survey.design.R index 74b15d5ee..e012238aa 100644 --- a/tests/testthat/test-ard_missing.survey.design.R +++ b/tests/testthat/test-ard_missing.survey.design.R @@ -103,3 +103,12 @@ test_that("ard_missing.survey.design() works", { cards::get_ard_statistics(stat_name %in% "p_nonmiss") |> unlist() |> unname() ) }) + +test_that("ard_missing.survey.design() follows ard structure", { + data(api, package = "survey") + svy_titanic <- survey::svydesign(~1, data = as.data.frame(Titanic), weights = ~Freq) + expect_silent( + ard_missing(svy_titanic, variables = c(Class, Age), by = NULL) |> + cards::check_ard_structure(method = FALSE) + ) +}) diff --git a/tests/testthat/test-ard_proportion_ci.R b/tests/testthat/test-ard_proportion_ci.R index 14c69ee3e..4d58c8143 100644 --- a/tests/testthat/test-ard_proportion_ci.R +++ b/tests/testthat/test-ard_proportion_ci.R @@ -119,3 +119,14 @@ test_that("ard_categorical_ci() messaging", { ) ) }) + +test_that("ard_proportion_ci() follows ard structure", { + expect_silent( + ard_categorical_ci( + data = mtcars, + variables = c(am, vs), + method = "waldcc" + ) |> + cards::check_ard_structure() + ) +}) diff --git a/tests/testthat/test-ard_regression.R b/tests/testthat/test-ard_regression.R index a547481f0..3ade0fec2 100644 --- a/tests/testthat/test-ard_regression.R +++ b/tests/testthat/test-ard_regression.R @@ -53,3 +53,11 @@ test_that("ard_regression() warnings and errors return correctly", { as.data.frame() ) }) + +test_that("ard_regression() follows ard structure", { + expect_silent( + lm(AGE ~ ARM, data = cards::ADSL) |> + ard_regression(add_estimate_to_reference_rows = TRUE) |> + cards::check_ard_structure(method = FALSE) + ) +}) diff --git a/tests/testthat/test-ard_regression_basic.R b/tests/testthat/test-ard_regression_basic.R index e9de71ffc..cd6ea499d 100644 --- a/tests/testthat/test-ard_regression_basic.R +++ b/tests/testthat/test-ard_regression_basic.R @@ -15,3 +15,11 @@ test_that("ard_regression_basic() works", { test_that("ard_regression_basic() does not produce `variable_level` column where not applicable", { expect_true(!"variable_level" %in% names(lm(mpg ~ hp, mtcars) |> ard_regression_basic())) }) + +test_that("ard_regression_basic() follows ard structure", { + expect_silent( + lm(AGE ~ ARM, data = cards::ADSL) |> + ard_regression_basic() |> + cards::check_ard_structure(method = FALSE) + ) +}) diff --git a/tests/testthat/test-ard_smd_smd.R b/tests/testthat/test-ard_smd_smd.R index 0744527ea..924d0f3b1 100644 --- a/tests/testthat/test-ard_smd_smd.R +++ b/tests/testthat/test-ard_smd_smd.R @@ -69,3 +69,11 @@ test_that("ard_smd_smd() error messaging", { "gref must be an integer within 2" ) }) + +test_that("ard_smd_smd() follows ard structure", { + expect_silent( + mtcars |> + ard_smd_smd(by = vs, variables = am, std.error = TRUE) |> + cards::check_ard_structure() + ) +}) diff --git a/tests/testthat/test-ard_stats_anova.R b/tests/testthat/test-ard_stats_anova.R index 1131cfbea..4342f79d4 100644 --- a/tests/testthat/test-ard_stats_anova.R +++ b/tests/testthat/test-ard_stats_anova.R @@ -143,3 +143,14 @@ test_that("ard_stats_anova.data.frame() error messaging", { grepl(pattern = "^Argument `method` cannot be namespaced*", x = _) ) }) + +test_that("ard_stats_anova() follows ard structure", { + expect_silent( + anova( + lm(mpg ~ am, mtcars), + lm(mpg ~ am + hp, mtcars) + ) |> + ard_stats_anova() |> + cards::check_ard_structure() + ) +}) diff --git a/tests/testthat/test-ard_stats_aov.R b/tests/testthat/test-ard_stats_aov.R index ad56ee6ba..c06b46f44 100644 --- a/tests/testthat/test-ard_stats_aov.R +++ b/tests/testthat/test-ard_stats_aov.R @@ -27,3 +27,10 @@ test_that("ard_aov() works", { as.data.frame() ) }) + +test_that("ard_stats_aov() follows ard structure", { + expect_silent( + ard_stats_aov(AGE ~ ARM, data = cards::ADSL) |> + cards::check_ard_structure(method = FALSE) + ) +}) diff --git a/tests/testthat/test-ard_stats_chisq_test.R b/tests/testthat/test-ard_stats_chisq_test.R index 0e99d39aa..938860b62 100644 --- a/tests/testthat/test-ard_stats_chisq_test.R +++ b/tests/testthat/test-ard_stats_chisq_test.R @@ -50,3 +50,11 @@ test_that("shuffle_ard fills missing group levels if the group is meaningful", { as.data.frame() ) }) + +test_that("ard_stats_chisq_test() follows ard structure", { + expect_silent( + cards::ADSL |> + ard_stats_chisq_test(by = ARM, variables = AGEGR1) |> + cards::check_ard_structure() + ) +}) diff --git a/tests/testthat/test-ard_stats_fisher_test.R b/tests/testthat/test-ard_stats_fisher_test.R index eb7d2033c..c0ad682ab 100644 --- a/tests/testthat/test-ard_stats_fisher_test.R +++ b/tests/testthat/test-ard_stats_fisher_test.R @@ -29,3 +29,11 @@ test_that("ard_stats_fisher_test() works", { ard_stats_fisher_test(by = ARM, variables = c(AGEGR1, BMIBLGR1)) ) }) + +test_that("ard_stats_fisher_test() follows ard structure", { + expect_silent( + cards::ADSL[1:20, ] |> + ard_stats_fisher_test(by = ARM, variables = AGEGR1) |> + cards::check_ard_structure() + ) +}) diff --git a/tests/testthat/test-ard_stats_kruskal_test.R b/tests/testthat/test-ard_stats_kruskal_test.R index fb4e96bdb..bbc50b971 100644 --- a/tests/testthat/test-ard_stats_kruskal_test.R +++ b/tests/testthat/test-ard_stats_kruskal_test.R @@ -36,3 +36,11 @@ test_that("ard_stats_kruskal_test() works", { ard_stats_kruskal_test(by = ARM, variable = c(AGE, BMIBL)) ) }) + +test_that("ard_stats_kruskal_test() follows ard structure", { + expect_silent( + cards::ADSL |> + ard_stats_kruskal_test(by = ARM, variable = BMIBL) |> + cards::check_ard_structure() + ) +}) diff --git a/tests/testthat/test-ard_stats_mcnemar_test.R b/tests/testthat/test-ard_stats_mcnemar_test.R index 6928a130c..7ae17ae4d 100644 --- a/tests/testthat/test-ard_stats_mcnemar_test.R +++ b/tests/testthat/test-ard_stats_mcnemar_test.R @@ -68,3 +68,11 @@ test_that("ard_stats_mcnemar_test() works", { ) expect_null(ard_stats_mcnemar_test_long$error |> unique() |> unlist()) }) + +test_that("ard_stats_mcnemar_test() follows ard structure", { + expect_silent( + cards::ADSL |> + ard_stats_mcnemar_test(by = SEX, variables = EFFFL) |> + cards::check_ard_structure() + ) +}) diff --git a/tests/testthat/test-ard_stats_mood_test.R b/tests/testthat/test-ard_stats_mood_test.R index 292399b4c..2cb0e0833 100644 --- a/tests/testthat/test-ard_stats_mood_test.R +++ b/tests/testthat/test-ard_stats_mood_test.R @@ -35,3 +35,11 @@ test_that("ard_stats_mood_test() works", { ard_stats_mood_test(by = SEX, variable = c(AGE, BMIBL)) ) }) + +test_that("ard_stats_mood_test() follows ard structure", { + expect_silent( + cards::ADSL |> + ard_stats_mood_test(by = SEX, variable = AGE) |> + cards::check_ard_structure() + ) +}) diff --git a/tests/testthat/test-ard_stats_oneway_test.R b/tests/testthat/test-ard_stats_oneway_test.R index 55edb7a07..001266563 100644 --- a/tests/testthat/test-ard_stats_oneway_test.R +++ b/tests/testthat/test-ard_stats_oneway_test.R @@ -27,3 +27,10 @@ test_that("ard_stats_oneway_test() works", { head(3) ) }) + +test_that("ard_stats_oneway_test() follows ard structure", { + expect_silent( + ard_stats_oneway_test(AGE ~ ARM, data = cards::ADSL) |> + cards::check_ard_structure() + ) +}) diff --git a/tests/testthat/test-ard_stats_prop_test.R b/tests/testthat/test-ard_stats_prop_test.R index 51b74adf6..73d632c67 100644 --- a/tests/testthat/test-ard_stats_prop_test.R +++ b/tests/testthat/test-ard_stats_prop_test.R @@ -85,3 +85,11 @@ test_that("ard_stats_prop_test() error messaging", { "The `by` column must have exactly 2 levels.\nThe levels are 4, 6, and 8" ) }) + +test_that("ard_stats_prop_test() follows ard structure", { + expect_silent( + mtcars |> + ard_stats_prop_test(by = vs, variables = am, conf.level = 0.90) |> + cards::check_ard_structure() + ) +}) diff --git a/tests/testthat/test-ard_stats_t_test.R b/tests/testthat/test-ard_stats_t_test.R index 9e487906a..7aedd3dba 100644 --- a/tests/testthat/test-ard_stats_t_test.R +++ b/tests/testthat/test-ard_stats_t_test.R @@ -115,3 +115,12 @@ test_that("ard_stats_paired_t_test() works", { FALSE ) }) + +test_that("ard_stats_t_test() follows ard structure", { + expect_silent( + cards::ADSL |> + dplyr::filter(ARM %in% c("Placebo", "Xanomeline High Dose")) |> + ard_stats_t_test(by = ARM, variable = AGE, var.equal = TRUE) |> + cards::check_ard_structure() + ) +}) diff --git a/tests/testthat/test-ard_stats_t_test_onesample.R b/tests/testthat/test-ard_stats_t_test_onesample.R index 60badde25..fa8949a85 100644 --- a/tests/testthat/test-ard_stats_t_test_onesample.R +++ b/tests/testthat/test-ard_stats_t_test_onesample.R @@ -48,3 +48,16 @@ test_that("ard_stats_t_test_onesample() works", { dplyr::tibble() |> cards::as_card() ) }) + +test_that("ard_stats_t_test_onesample() follows ard structure", { + expect_silent( + ard_stats_t_test_onesample( + cards::ADSL, + variables = AGE, + by = ARM, + conf.level = 0.9, + mu = 1 + ) |> + cards::check_ard_structure() + ) +}) diff --git a/tests/testthat/test-ard_stats_wilcox_test.R b/tests/testthat/test-ard_stats_wilcox_test.R index a8fc09e1d..322a4ac57 100644 --- a/tests/testthat/test-ard_stats_wilcox_test.R +++ b/tests/testthat/test-ard_stats_wilcox_test.R @@ -122,3 +122,12 @@ test_that("ard_stats_paired_wilcox_test() works", { "The `by` argument must have two and only two levels." ) }) + +test_that("ard_stats_wilcox_test() follows ard structure", { + expect_silent( + cards::ADSL |> + dplyr::filter(ARM %in% c("Placebo", "Xanomeline High Dose")) |> + ard_stats_wilcox_test(by = ARM, variable = AGE, correct = FALSE, conf.int = TRUE) |> + cards::check_ard_structure() + ) +}) diff --git a/tests/testthat/test-ard_stats_wilcox_test_onesample.R b/tests/testthat/test-ard_stats_wilcox_test_onesample.R index 4366938ba..3247e8a33 100644 --- a/tests/testthat/test-ard_stats_wilcox_test_onesample.R +++ b/tests/testthat/test-ard_stats_wilcox_test_onesample.R @@ -50,3 +50,17 @@ test_that("ard_stats_wilcox_test_onesample() works", { dplyr::tibble() |> cards::as_card() ) }) + +test_that("ard_stats_wilcox_test_onesample() follows ard structure", { + expect_silent( + ard_stats_wilcox_test_onesample( + cards::ADSL, + variables = AGE, + by = ARM, + conf.level = 0.9, + conf.int = TRUE, + mu = 1 + ) |> + cards::check_ard_structure() + ) +}) diff --git a/tests/testthat/test-ard_survey_svychisq.R b/tests/testthat/test-ard_survey_svychisq.R index 1d780f0dd..86ed81e4b 100644 --- a/tests/testthat/test-ard_survey_svychisq.R +++ b/tests/testthat/test-ard_survey_svychisq.R @@ -65,3 +65,17 @@ test_that("ard_survey_svychisq() works", { ard_svychisq[c("context", "stat_name", "stat_label", "stat")] ) }) + +test_that("ard_survey_svychisq() follows ard structure", { + data(api, package = "survey") + dclus2 <- survey::svydesign(id = ~ dnum + snum, fpc = ~ fpc1 + fpc2, data = apiclus2) + expect_silent( + ard_survey_svychisq( + dclus2, + variables = sch.wide, + by = comp.imp, + statistic = "F" + ) |> + cards::check_ard_structure() + ) +}) diff --git a/tests/testthat/test-ard_survey_svyranktest.R b/tests/testthat/test-ard_survey_svyranktest.R index 610beb4ae..9df43c185 100644 --- a/tests/testthat/test-ard_survey_svyranktest.R +++ b/tests/testthat/test-ard_survey_svyranktest.R @@ -39,3 +39,17 @@ test_that("exact values match for ard_svyranktest works", { ignore_attr = TRUE ) }) + +test_that("ard_survey_svyranktest() follows ard structure", { + data(api, package = "survey") + dclus2 <- survey::svydesign(id = ~ dnum + snum, fpc = ~ fpc1 + fpc2, data = apiclus2) + expect_silent( + ard_survey_svyranktest( + dclus2, + variable = enroll, + by = comp.imp, + test = "wilcoxon" + ) |> + cards::check_ard_structure() + ) +}) diff --git a/tests/testthat/test-ard_survey_svyttest.R b/tests/testthat/test-ard_survey_svyttest.R index c1d04eb34..ece44b7e3 100644 --- a/tests/testthat/test-ard_survey_svyttest.R +++ b/tests/testthat/test-ard_survey_svyttest.R @@ -73,3 +73,17 @@ test_that("ard_survey_svyttest() messaging", { "group must be binary" ) }) + +test_that("ard_survey_svyttest() follows ard structure", { + data(api, package = "survey") + dclus2 <- survey::svydesign(id = ~ dnum + snum, fpc = ~ fpc1 + fpc2, data = apiclus2) + expect_silent( + ard_survey_svyttest( + dclus2, + variable = enroll, + by = comp.imp, + conf.level = 0.9 + ) |> + cards::check_ard_structure() + ) +}) diff --git a/tests/testthat/test-ard_survival_survdiff.R b/tests/testthat/test-ard_survival_survdiff.R index 1ae555b10..6dd8eb13e 100644 --- a/tests/testthat/test-ard_survival_survdiff.R +++ b/tests/testthat/test-ard_survival_survdiff.R @@ -60,3 +60,10 @@ test_that("ard_survival_survdiff() error messaging", { ard_survival_survdiff$error |> unique() |> grepl(pattern = "*'not_a_variable'*", x = _) ) }) + +test_that("ard_survival_survdiff() follows ard structure", { + expect_silent( + ard_survival_survdiff(survival::Surv(AVAL, CNSR) ~ TRTA, data = cards::ADTTE) |> + cards::check_ard_structure() + ) +}) diff --git a/tests/testthat/test-ard_survival_survfit.R b/tests/testthat/test-ard_survival_survfit.R index d12d4ac32..f84857c21 100644 --- a/tests/testthat/test-ard_survival_survfit.R +++ b/tests/testthat/test-ard_survival_survfit.R @@ -141,3 +141,12 @@ test_that("ard_survival_survfit() errors with stratified Cox model", { ard_survival_survfit() ) }) + + +test_that("ard_survival_survfit() follows ard structure", { + expect_silent( + survival::survfit(survival::Surv(AVAL, CNSR) ~ TRTA, cards::ADTTE) |> + ard_survival_survfit(times = c(60, 180)) |> + cards::check_ard_structure(method = FALSE) + ) +}) diff --git a/tests/testthat/test-ard_survival_survfit_diff.R b/tests/testthat/test-ard_survival_survfit_diff.R index e1f00dd9a..f99146874 100644 --- a/tests/testthat/test-ard_survival_survfit_diff.R +++ b/tests/testthat/test-ard_survival_survfit_diff.R @@ -61,3 +61,12 @@ test_that("ard_survival_survfit_diff() messaging", { ard_survival_survfit_diff(times = c(25, 50)) ) }) + +test_that("ard_survival_survfit_diff() follows ard structure", { + withr::local_package("survival") + sf <- survfit(Surv(AVAL, 1 - CNSR) ~ SEX, cards::ADTTE) + expect_silent( + ard_survival_survfit_diff(sf, times = c(25, 50)) |> + cards::check_ard_structure() + ) +})