test_that("longitrees returns correct class", { data(ltreedata) res <- longitrees(y ~ ., time = "time", random = "subject", weight = 0.2, data = ltreedata, gamma = 1.5, bootsize = 30, mins = 40) expect_s3_class(res, "longitrees") }) test_that("threetrees returns correct class", { pdf(NULL) on.exit(dev.off(), add = TRUE) data(ltreedata) res <- longitrees(y ~ ., time = "time", random = "subject", weight = 0.2, data = ltreedata, gamma = 1.5, bootsize = 30, mins = 40) sel <- selectionplot(res, metric = "PE", nth = 1) tt <- threetrees(res, selection = sel) expect_s3_class(tt, "threetrees") expect_output(summary(tt)) expect_output(print(tt)) }) test_that("predict.threetrees returns data frame", { pdf(NULL) on.exit(dev.off(), add = TRUE) data(ltreedata) res <- longitrees(y ~ ., time = "time", random = "subject", weight = 0.2, data = ltreedata, gamma = 1.5, bootsize = 30, mins = 40) sel <- selectionplot(res, metric = "PE", nth = 1) tt <- threetrees(res, selection = sel) pred <- predict(tt, tree = 1) expect_true(is.data.frame(pred)) }) test_that("predict.threetrees errors on invalid tree", { dummy <- structure(list(), class = "threetrees") expect_error(predict(dummy, tree = 5), "tree must be 1, 2, or 3") })