tests/testthat/test-developer-fastlag.R

test_that("internal function fastlag() produces expected results", {
  observed <- gsDesign2:::fastlag(1:5, first = 100)
  expected <- c(100, 1:4)
  expect_equal(observed, expected)

  # can also work with list()
  observed <- gsDesign2:::fastlag(list(1, 2, 3, 4, 5), first = 100)
  expected <- list(100, 1, 2, 3, 4)
  expect_equal(observed, expected)
})

test_that("internal function fastlag() throws errors for bad inputs", {
  expect_error(gsDesign2:::fastlag(1:5))
  expect_error(gsDesign2:::fastlag(1:5, default = 100))
  expect_error(gsDesign2:::fastlag(data.frame(), first = 100))
  expect_error(gsDesign2:::fastlag(1:5, first = data.frame()))
  expect_error(gsDesign2:::fastlag(c(), first = 100))
  expect_error(gsDesign2:::fastlag(1:5, first = c()))
  expect_error(gsDesign2:::fastlag(1:5, first = 1:2))
})

Try the gsDesign2 package in your browser

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

gsDesign2 documentation built on April 3, 2025, 9:39 p.m.