test_that("mynca example runs", { ex <- mynca_example() expect_true(is.data.frame(ex)) res <- mynca(data = ex) expect_true(is.list(res)) expect_true("summary" %in% names(res)) expect_true(nrow(res$summary) > 0) expect_true(all(c("tinf", "c_end_infusion", "auc_0_tinf", "accum_auc_tau", "accum_cmax") %in% names(res$summary))) }) test_that("column aliases and BLQ rules are handled", { alias_df <- data.frame( USUBJID = c("S1", "S1", "S1", "S1", "S1", "S1"), TIME = c(0, 0, 1, 2, 12, 12), DV = c(NA, 5, 3, 1.5, NA, 0.3), AMT = c(100, NA, NA, NA, 100, NA), ROUTE = c("IV", "IV", "IV", "IV", "PO", "PO"), TINF = c(1, NA, NA, NA, NA, NA), PERIOD = c(1, 1, 1, 1, 2, 2), ARM = c("A", "A", "A", "A", "A", "A"), COHORT = c(1, 1, 1, 1, 1, 1), BLQ = c(0, 0, 0, 0, 1, 0), LLOQ = c(0.1, 0.1, 0.1, 0.1, 0.1, 0.1) ) res <- mynca( data = alias_df, blq_handling = "pre_zero_post_drop" ) expect_true(nrow(res$summary) > 0) expect_true(all(res$summary$tinf[!is.na(res$summary$tinf)] >= 0)) expect_true("auc_0_tinf" %in% names(res$summary)) }) test_that("mynca_report writes csv and plot outputs", { res <- mynca(data = mynca_example()) out_dir <- file.path(tempdir(), "mynca_report_test") paths <- mynca_report( result = res, output_dir = out_dir, prefix = "unit", write_csv = TRUE, write_plots = TRUE, plot_format = "pdf" ) expect_true(file.exists(paths$csv$summary)) expect_true(file.exists(paths$csv$population)) expect_true(file.exists(paths$csv$intervals)) expect_true(file.exists(paths$settings)) expect_true(length(paths$plots) >= 1) })