# tests/testthat/helper.R # Shared test helpers — sourced automatically by testthat before each test file #' Build a simple paired (x, y) data frame for regression tests make_xy <- function(n = 50, seed = 1, noise = 0.2) { set.seed(seed) x <- seq(0, 10, length.out = n) y <- 2 + 1.5 * x + rnorm(n, 0, noise) data.frame(x = x, y = y) } #' Logistic growth data (clean, easy to fit) make_growth <- function(n = 80, seed = 7) { set.seed(seed) days <- seq(1, 120, length.out = n) bm <- 400 / (1 + exp((50 - days) / 9)) + rnorm(n, 0, 8) data.frame(days = days, biomass_g = pmax(bm, 0)) } #' Suppress expected informational messages during tests quietly <- function(expr) suppressMessages(suppressWarnings(expr))