test_that("gui_isotherm supports temkin, dr, sips", { df <- data.frame(Ce = c(2, 5, 10, 20, 35, 50, 70, 90), qe = c(0.8, 1.6, 2.3, 3.0, 3.6, 4.0, 4.4, 4.6)) for (m in c("temkin", "dr", "sips")) { res <- gui_isotherm(df, "Ce", "qe", m) expect_equal(res$model, m) expect_equal(nrow(res$params), 1) } }) test_that("gui_isotherm_batch fits per group", { df <- data.frame( id = rep(c("A", "B"), each = 6), Ce = rep(c(2, 5, 10, 20, 35, 50), 2), qe = c(0.8, 1.6, 2.3, 3.0, 3.6, 4.0, 0.5, 1.0, 1.6, 2.2, 2.7, 3.0) ) res <- gui_isotherm_batch(df, "id", "Ce", "qe", "langmuir") expect_equal(nrow(res), 2) }) test_that("gui_kinetics supports elovich and intraparticle", { df <- data.frame(t = c(5, 15, 30, 60, 120, 240), qt = c(1.2, 2.1, 2.9, 3.6, 4.0, 4.2)) for (m in c("elovich", "intraparticle")) { res <- gui_kinetics(df, "t", "qt", m) expect_equal(res$model, m) } }) test_that("gui_kinetics_batch fits per group", { df <- data.frame( id = rep(c("A", "B"), each = 6), t = rep(c(5, 15, 30, 60, 120, 240), 2), qt = c(1.2, 2.1, 2.9, 3.6, 4.0, 4.2, 0.8, 1.5, 2.0, 2.5, 2.8, 3.0) ) res <- gui_kinetics_batch(df, "id", "t", "qt", "pso") expect_equal(nrow(res), 2) }) test_that("gui_vant_hoff works end to end", { df <- data.frame(T = c(298, 308, 318, 328), Kc = c(1.8, 2.3, 2.9, 3.4)) res <- gui_vant_hoff(df, "T", "Kc") expect_true(is.finite(res$deltaH_kJmol)) }) test_that("gui_bet works end to end", { df <- data.frame(PP0 = c(0.05, 0.10, 0.15, 0.20, 0.25, 0.30), Q = c(12.1, 15.8, 18.9, 21.6, 24.1, 26.8)) res <- gui_bet(df, "PP0", "Q") expect_true(res$SBET_m2g > 0) }) test_that("gui_proximate works with and without id column", { df <- data.frame(id = "s1", moisture = 3.2, vm = 28.5, ash = 12.1) out <- gui_proximate(df, "moisture", "vm", "ash", "id") expect_true("id" %in% names(out)) expect_equal(out$fixed_carbon_pct, 56.2) out2 <- gui_proximate(df, "moisture", "vm", "ash") expect_false("id" %in% names(out2)) }) test_that("gui_ultimate works with and without N column", { df <- data.frame(C = 65.2, H = 2.8, O = 18.4, N = 1.1) out <- gui_ultimate(df, "C", "H", "O", "N") expect_true("NC_ratio" %in% names(out)) out2 <- gui_ultimate(df, "C", "H", "O") expect_false("NC_ratio" %in% names(out2)) }) test_that("gui_xrd_deconvolve works end to end", { set.seed(1) two_theta <- seq(10, 40, by = 0.1) intensity <- pmax(0, 300 * exp(-((two_theta - 22)^2) / (2 * 0.8^2)) + stats::rnorm(length(two_theta), 0, 3)) df <- data.frame(tt = two_theta, i = intensity) res <- gui_xrd_deconvolve(df, "tt", "i", peak_centers = 22) expect_equal(nrow(res$peaks), 1) }) test_that("gui_xrd_deconvolve errors with no peak centers", { df <- data.frame(tt = 1:10, i = 1:10) expect_error(gui_xrd_deconvolve(df, "tt", "i", peak_centers = numeric(0)), "at least one") }) test_that("gui_ftir_baseline and gui_ftir_autopeaks work end to end", { wn <- seq(4000, 400, by = -4) df <- data.frame(wn = wn, i = 0.1 + exp(-((wn - 1710)^2) / (2 * 20^2))) corrected <- gui_ftir_baseline(df, "wn", "i", "rolling_min") expect_true(max(corrected$intensity) > 0.8) peaks <- gui_ftir_autopeaks(df, "wn", "i", min_prominence = 0.05) expect_true(nrow(peaks) >= 1) })