context("Testing hello_world_function")
test_that("Returns expected string when name is null", {
ss <- hello_world_function()
expect_equal(ss, 'Hello World')
})
test_that("Returns expected string when name is not null", {
ss <- hello_world_function('Trevor')
expect_equal(ss, 'Hello Trevor')
})
test_that("Error messages are working properly",{
testthat::expect_error(hello_world_function(NA)
, "The name is NA. Need to know who to say hello to.")
testthat::expect_error(hello_world_function(2)
, "The name must be a character")
testthat::expect_error(hello_world_function(c('Trevor','Trevor'))
, "The name must only be of length 1.")
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.