tests/testthat/test-check-assert_scalar_date.R

# Tests de résultats positifs --------------------------------------------------

testthat::test_that("good result for Date", {

    date <- Sys.Date()
    res <- testthat::expect_silent(assert_scalar_date(x = date))
    testthat::expect_identical(res, date)

})


# Tests de résultats négatifs --------------------------------------------------

testthat::test_that("Several Date are not allowed", {

    testthat::expect_error(
        assert_scalar_date(x = seq(from = as.Date("2023-08-04"), to = as.Date("2024-08-04"), by = "months"))
    )

})

Try the TractorTsbox package in your browser

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

TractorTsbox documentation built on April 4, 2025, 4:11 a.m.