tests/testthat/test_sum.R

testthat::context("Test example sum function")

testthat::test_that("The sum function works", {
  testthat::expect_equal(peg_sum("12,14,19,2"), 47)
})

testthat::test_that("The sum function works vectorised", {
  testthat::expect_equal(length(peg_sum(c("12,14,19,2", NA_character_))), 2)
})

testthat::test_that("The sum function works with NAs", {
  testthat::expect_true(is.na(peg_sum(NA_character_)))
})

Try the piton package in your browser

Any scripts or data that you put into this service are public.

piton documentation built on Nov. 16, 2020, 9:13 a.m.