tests/testthat/test-rschedule.R

# ------------------------------------------------------------------------------
# new_rschedule()

test_that("must supply at least one field", {
  expect_snapshot(error = TRUE, {
    new_rschedule(class = "foo")
  })
})

test_that("must supply named fields", {
  expect_snapshot(error = TRUE, {
    new_rschedule(1, "foo")
  })
})

test_that("class is required", {
  expect_error(new_rschedule(x = 1))
})

test_that("can create rschedule subclasses", {
  x <- new_rschedule(x = 1, class = "foobar")
  expect_identical(x, structure(list(x = 1), class = c("foobar", "almanac_rschedule")))
})

# ------------------------------------------------------------------------------
# rschedule_events()

test_that("default method errors", {
  expect_snapshot(error = TRUE, {
    rschedule_events(1)
  })
})

test_that("method is required for subclasses", {
  x <- new_rschedule(x = 1, class = "foobar")
  expect_snapshot(error = TRUE, {
    rschedule_events(x)
  })
})

Try the almanac package in your browser

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

almanac documentation built on April 14, 2023, 12:23 a.m.