tests/testthat/test-invalid.R

# ------------------------------------------------------------------------------
# invalid_remove()

test_that("can remove invalid dates from calendar types", {
  x <- year_month_day(2020, 2, 28:30)
  expect_identical(invalid_remove(x), x[1:2])

  x <- year_day(2019, 365:366)
  expect_identical(invalid_remove(x), x[1L])
})

test_that("errors on unsupported types", {
  expect_snapshot(error = TRUE, invalid_remove(1))
})

Try the clock package in your browser

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

clock documentation built on Sept. 11, 2024, 8:39 p.m.