test_that("seair_params validates inputs", {
  expect_s3_class(
    seair_params(1, 0.3, 0.2, 0.1, 0.13, 0.5, 0.3),
    "seair_params")
  expect_error(seair_params(-1, 0.3, 0.2, 0.1, 0.13))
  expect_error(seair_params(1, 0.3, 0.2, 0.1, 0.13, alpha = 2))
  expect_error(seair_params(1, 0.3, 0.2, 0.1, 0.13, delta = 0))
})

test_that("seair_init normalises f and stores grid", {
  m <- seq(0, 1, length.out = 101)
  f <- rep(1, length(m))    # uniform, unnormalised
  init <- seair_init(m, f, I_seed = 0.01)
  w <- (function(x) {
    n <- length(x)
    w <- numeric(n)
    w[1] <- (x[2] - x[1]) / 2
    w[n] <- (x[n] - x[n - 1]) / 2
    if (n > 2) w[2:(n - 1)] <- (x[3:n] - x[1:(n - 2)]) / 2
    w
  })(m)
  expect_equal(sum(w * init$f), 1, tolerance = 1e-10)
  expect_equal(sum(w * init$S), 1 - 0.01, tolerance = 1e-10)
  expect_equal(sum(w * init$I), 0.01,     tolerance = 1e-10)
})
