# WARNING - Generated by {fusen} from dev/flat_kwb_simulate_inflow.Rmd: do not edit by hand # nolint: line_length_linter. test_that("catAndRun works correctly", { # Test basic functionality output <- capture.output(catAndRun("Test message", {cat("Running test")}, dbg = TRUE, log_time = FALSE)) expect_true(grepl("Test message ... Running testok.", paste(output, collapse = " "))) # Test with newLine = 0 output <- capture.output(catAndRun("Test message", {cat("Running test")}, newLine = 0L, dbg = TRUE, log_time = FALSE)) expect_true(grepl("Test message ... Running testok.", paste(output, collapse = " "))) # Test with newLine = 1 output <- capture.output(catAndRun("Test message", {cat("Running test")}, newLine = 1L, dbg = TRUE, log_time = FALSE)) combined <- paste(output, collapse = " ") expect_true(grepl("Test message ...", combined)) expect_true(grepl("Running testok.", combined)) # Test with dbg = FALSE output <- capture.output(catAndRun("Test message", {cat("Running test")}, dbg = FALSE)) expect_true(grepl(c("Running test"), paste(output, collapse = " "))) # Test return value result <- catAndRun("Test message", {1 + 1}, dbg = FALSE) expect_equal(result, 2) })