test_that("gui_parse_ids works on a data frame column", { df <- data.frame(sample = c("SBC300-15", "SBC450-30")) out <- gui_parse_ids(df, "sample") expect_equal(out$temperature_C, c(300, 450)) }) test_that("gui_adsorption computes qe and removal, with optional id column", { df <- data.frame(id = c("s1", "s2"), C0 = c(50, 50), Ce = c(12.5, 25), V = c(0.05, 0.05), m = c(0.1, 0.1)) out <- gui_adsorption(df, "C0", "Ce", "V", "m", id_col = "id") expect_equal(out$qe_mgg, c(18.75, 12.5)) expect_equal(out$removal_pct, c(75, 50)) expect_true("id" %in% names(out)) }) test_that("gui_adsorption errors on missing columns", { df <- data.frame(C0 = 50, Ce = 10) expect_error(gui_adsorption(df, "C0", "Ce", "V", "m"), "not found") }) test_that("gui_isotherm fits langmuir and returns params/plot inputs", { set.seed(1) Ce <- c(2, 5, 10, 20, 35, 50, 70) qe <- (5 * 0.15 * Ce) / (1 + 0.15 * Ce) + stats::rnorm(length(Ce), 0, 0.02) df <- data.frame(Ce = Ce, qe = qe) res <- gui_isotherm(df, "Ce", "qe", "langmuir") expect_equal(res$model, "langmuir") expect_true(res$fit$R2 > 0.9) expect_equal(nrow(res$params), 1) }) test_that("gui_kinetics fits pso", { set.seed(4) t <- c(5, 15, 30, 60, 120, 240) qt <- 4.2 * (1 - exp(-0.05 * t)) + stats::rnorm(length(t), 0, 0.02) df <- data.frame(t = t, qt = qt) res <- gui_kinetics(df, "t", "qt", "pfo") expect_equal(res$model, "pfo") expect_true(res$fit$R2 > 0.9) }) test_that("gui_ftir_density and gui_ftir_peaks work", { spec <- data.frame(wn = seq(4000, 500, by = -10), i = stats::runif(351)) out <- gui_ftir_density(spec, "wn", "i") expect_equal(nrow(out$table), nrow(biocharkit::ftir_band_reference())) peaks <- data.frame(p = c(3420, 2920, 1710)) out2 <- gui_ftir_peaks(peaks, "p") expect_equal(out2$group[1], "O-H stretch") }) test_that("gui_xrd_ci computes crystallinity index", { df <- data.frame(cryst = 1200, amorph = 800) out <- gui_xrd_ci(df, "cryst", "amorph") expect_equal(out$crystallinity_index, 0.6) }) test_that("gui_correlation returns long-format results with p-values", { df <- data.frame(temp = c(300, 450, 600, 300, 450, 600), EC = c(1.1, 1.8, 2.6, 1.0, 1.9, 2.5)) out <- gui_correlation(df, c("temp", "EC"), "spearman") expect_equal(nrow(out$long), 1) expect_true(out$long$rho > 0.8) }) test_that("gui_correlation errors with fewer than two columns", { df <- data.frame(temp = c(300, 450, 600)) expect_error(gui_correlation(df, "temp"), "at least two") })