test_that("longitree returns correct class with gamma", { data(ltreedata) result <- longitree(y ~ ., time = "time", random = "subject", weight = 0.2, data = ltreedata, gamma = 1.5) expect_s3_class(result, "longitree") expect_true(!is.null(result$rsplitmat)) expect_true(!is.null(result$rpredict)) expect_true(!is.null(result$nmat)) }) test_that("longitree errors when no method is specified", { expect_error( longitree(y ~ x, time = "t", random = "id", data = data.frame(y = 1, x = 1, t = 1, id = 1)), "alpha, gamma, or cv" ) }) test_that("longitree errors when multiple methods are specified", { expect_error( longitree(y ~ x, time = "t", random = "id", data = data.frame(y = 1, x = 1, t = 1, id = 1), alpha = 0.05, gamma = 1.5), "Only one of" ) }) test_that("summary.longitree produces output", { data(ltreedata) result <- longitree(y ~ ., time = "time", random = "subject", weight = 0.2, data = ltreedata, gamma = 1.5) expect_output(summary(result)) expect_output(print(result)) }) test_that("longitree works with alpha method", { data(ltreedata) result <- longitree(y ~ ., time = "time", random = "subject", weight = 0.2, data = ltreedata, alpha = 0.05) expect_s3_class(result, "longitree") })