tests/testthat/test-roxytest-tests-surv_function.r

# Generated by roxytest: Do not edit by hand!

# File R/surv_function.r: @tests

test_that("Function surv_prob.surv_function() @ L34", {
  dist1 <- define_surv_func(
   pweibull,
   lower.tail = FALSE,
   shape = 1.2,
   scale = 20.1
  )
  expect_equal(
   surv_prob(dist1, c(0, 1, 2, 3)),
   c(1.0000000, 0.9730691, 0.9392071, 0.9030062),
   tolerance = 0.00001
  )
})


test_that("Function print.surv_function() @ L72", {
  surv_dist1 <- define_surv_func(function(x) x+1, shape=1.2,scale=30.1,lower.tail = FALSE)
  expect_output(
   print(surv_dist1),
   "A survival distribution based on a custom function.\n  Arguments: shape = 1.2, scale = 30.1, lower.tail = FALSE\n  Function: function(x) x+1",
   fixed = T
  )
  surv_dist2 <- define_surv_func(pweibull, shape=1.2,scale=30.1,lower.tail = FALSE)
  fun <- function(x) x+1
  expect_output(
   print(surv_dist2),
   "A survival distribution based on a custom function.\n  Arguments: shape = 1.2, scale = 30.1, lower.tail = FALSE\n  Function:\n    function (q, shape, scale = 1, lower.tail = TRUE, log.p = FALSE)",
   fixed = T
  )
  surv_dist3 <- define_surv_func(function(x) x+1, shape=1.2,scale=c(30.1, 30.2),lower.tail = FALSE)
  expect_output(
   print(surv_dist3),
   "A survival distribution based on a custom function.\n  Arguments:\n    $shape\n    [1] 1.2",
   fixed = T
  )
  
  surv_dist4 <- define_surv_func(function(x) x+1)
  expect_output(
   print(surv_dist4),
   "A survival distribution based on a custom function: function(x) x+1",
   fixed = T
  )
})
PolicyAnalysisInc/herosurv documentation built on May 21, 2023, 10:12 a.m.