# WARNING - Generated by {fusen} from dev/flat_kwb_simulate_inflow.Rmd: do not edit by hand # nolint: line_length_linter. test_that("selectColumns works correctly", { df <- data.frame(a = 1:3, b = letters[1:3], c = c(TRUE, FALSE, TRUE)) # Test with explicit columns expect_equal(selectColumns(df, columns = c("a", "b")), df[, c("a", "b")]) # Test with pattern expect_equal(selectColumns(df, pattern = "a|b"), df[, c("a", "b")]) # Test with drop = TRUE expect_equal(selectColumns(df, columns = "a", drop = TRUE), df$a) # Test with non-existing columns (do.stop = FALSE warns instead of stopping) expect_warning(res <- selectColumns(df, columns = c("a", "x"), do.stop = FALSE), "No such column") expect_equal(res, df[, "a"]) # Test with NULL columns expect_equal(selectColumns(df, columns = NULL), df) # Test with NA columns expect_equal(selectColumns(df, columns = NA), df) # Test with empty columns expect_equal(selectColumns(df, columns = character(0)), df) # Test with non-data frame input expect_error(selectColumns(1:3, columns = "a"), ".*must be a data frame.*") })