tests/testthat/test-Main.R

# Unit tests on the DidacticBoost package
if(require(rpart) & require(testthat)){
  context("Testing the package")
  test_that("Testing invalid inputs", {
    k <- kyphosis
    k$Kyphosis <- factor(ifelse(k$Kyphosis == "present", 1L, -1L))
    expect_that(fit <- fitBoosted(Kyphosis ~ Age + Number + Start, data = k, iterations = 10), not(throws_error()))
    fit <- fitBoosted(Kyphosis ~ Age + Number + Start, data = k, iterations = 10)
    expect_true(is.boosted(fit))
    expect_that(predict(fit), not(throws_error()))
    expect_that(predict(fit, newdata = k), not(throws_error()))
  })
}
dashaub/DidacticBoost documentation built on May 14, 2019, 6:11 p.m.