test_that("correlation_matrix returns matching estimate/p-value matrices", { 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), pH = c(7.1, 8.0, 9.2, 7.0, 8.1, 9.0)) res <- correlation_matrix(df, method = "spearman") expect_equal(dim(res$estimate), c(3, 3)) expect_equal(dim(res$p_value), c(3, 3)) expect_equal(unname(diag(res$estimate)), c(1, 1, 1)) expect_true(res$estimate["temp", "EC"] > 0.8) }) test_that("correlation_matrix drops non-numeric columns with a message", { df <- data.frame(id = c("a", "b", "c"), x = c(1, 2, 3), y = c(3, 2, 1)) expect_message(res <- correlation_matrix(df), "Dropping non-numeric") expect_equal(colnames(res$estimate), c("x", "y")) }) test_that("assign_ftir_peaks matches known ranges", { out <- assign_ftir_peaks(c(3420, 2920, 1710)) expect_equal(out$group, c("O-H stretch", "Aliphatic C-H", "C=O stretch")) }) test_that("assign_ftir_peaks returns NA for unmatched peaks", { out <- assign_ftir_peaks(c(500)) expect_true(is.na(out$group[1])) }) test_that("functional_group_density returns one row per reference group", { spectrum <- data.frame( wavenumber_cm1 = seq(4000, 500, by = -10), intensity = stats::runif(351, 0, 1) ) out <- functional_group_density(spectrum) expect_equal(nrow(out), nrow(ftir_band_reference())) })