# Generated by roxytest: Do not edit by hand!
# File R/util.r: @tests
test_that("Function is_surv_dist() @ L6", {
expect_equal(is_surv_dist(create_list_object('flexsurvreg')), TRUE)
expect_equal(is_surv_dist(create_list_object('tibble')), FALSE)
expect_equal(is_surv_dist(create_list_object(c('foo', 'surv_km'))), TRUE)
})
test_that("Function get_and_populate_message() @ L29", {
expect_equal(
get_and_populate_message('missing_parameters', dist = 'a', params = 'b'),
'Error defining a distribution, parameters missing from function call: b.'
)
})
test_that("Function truncate_param() @ L56", {
expect_equal(
truncate_param('foo', c(1)),
1
)
expect_equal(
truncate_param('foo', c(1,1,1)),
1
)
expect_warning(
truncate_param('foo', c(1,2,3)),
'Parameter foo was length > 1 and only the first element will be used.',
fixed = T
)
expect_equal(
suppressWarnings(truncate_param('foo', c(1,2,3))),
1
)
})
test_that("Function check_times() @ L97", {
expect_error(
check_times(c(0,1,2,3), '', ''),
NA
)
expect_error(
check_times("blah", 'foo', 'bar'),
'Error foo, "bar" must be numeric.'
)
expect_error(
check_times(c(0,1,-2,3), 'foo', 'bar'),
'Error foo, "bar" cannot be negative.'
)
expect_error(
check_times(c(0,1,NA_real_,3), 'foo', 'bar'),
'Error foo, "bar" cannot be NA.'
)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.