test_that("print.slim produces output", { set.seed(401) x <- matrix(rnorm(120), nrow = 30, ncol = 4) y <- x[, 1] + rnorm(30) * 0.5 fit <- slim(x, y, nlambda = 3, method = "lasso", verbose = FALSE, max.ite = 2000) out <- capture.output(print(fit)) expect_true(any(grepl("slim options summary", out))) expect_true(any(grepl("lasso", out))) }) test_that("plot.slim runs without error", { set.seed(402) x <- matrix(rnorm(120), nrow = 30, ncol = 4) y <- x[, 1] + rnorm(30) * 0.5 fit <- slim(x, y, nlambda = 3, method = "lasso", verbose = FALSE, max.ite = 2000) expect_no_error(plot(fit)) }) test_that("print.sugm produces output", { set.seed(403) x <- matrix(rnorm(200), nrow = 40, ncol = 5) fit <- sugm(x, nlambda = 3, method = "clime", verbose = FALSE, max.ite = 2000) out <- capture.output(print(fit)) expect_true(any(grepl("sugm options summary", out))) expect_true(any(grepl("clime", out))) }) test_that("print.sim produces output", { sim <- sugm.generator(n = 50, d = 10, graph = "random", seed = 1, verbose = FALSE) out <- capture.output(print(sim)) expect_true(any(grepl("Simulated data", out))) expect_true(any(grepl("random", out))) }) test_that("coef.slim rejects out-of-range indices", { set.seed(405) x <- matrix(rnorm(120), nrow = 30, ncol = 4) y <- x[, 1] + rnorm(30) * 0.5 fit <- slim(x, y, nlambda = 3, method = "lasso", verbose = FALSE, max.ite = 2000) expect_error( coef(fit, lambda.idx = 100, beta.idx = 100), "out of range" ) })