# SVN revision:
# Date of last change: 2014-10-01
# Last changed by: ccampbell
#
# Original author: ccampbell
# Copyright Mango Solutions, Chippenham, UK 2013-2014
###############################################################################
context("calculate fibonacci numbers complete")
test_that("hit some symbols", {
expect_that(fib(1), equals(1))
expect_that(fib(2), equals(c(1, 1)))
expect_that(fib(3), equals(c(1, 1, 2)))
expect_that(fib(4), equals(c(1, 1, 2, 3)))
expect_that(fib(5), equals(c(1, 1, 2, 3, 5)))
})
test_that("hit error checking symbols", {
wn <- getOption("warn")
options("warn" = -1)
expect_that(fib("a"), throws_error("n not recognized"))
expect_that(fib(), throws_error("'n' is missing"))
expect_that(fib(0), throws_error("n should be an integer greater than 0"))
expect_that(fib(Inf), throws_error("n not recognized"))
options("warn" = wn)
expect_that(fib(1:3), throws_error("n must be length 1"))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.