tests/testthat/test-limit.R

test_that("limit() works", {
  expect_equal(limit(1:6, 2, 4), c(2, 2, 3, 4, 4, 4))
  expect_equal(limit(1:6, 2L, 4L), c(2L, 2L, 3L, 4L, 4L, 4L))
})

test_that("limit() errors", {
  expect_error(limit(1, "a", 1), class = "simpleError")
  expect_error(limit(1, 1:2, 1), class = "simpleError")
  expect_error(limit(1, 1, "a"), class = "simpleError")
  expect_error(limit(1, 1, 1:2), class = "simpleError")
  expect_error(limit(1, 2, 1),   class = "simpleError")
})

Try the mark package in your browser

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

mark documentation built on May 29, 2024, 5:13 a.m.