tests/testthat/test-utils_coerce_time_class.R

test_that("`utils_coerce_time_class()` works", {
  x <- utils_coerce_time_class(
    x = c("2024-01-01", "2024-02-01"),
    to = "Date"
  )
  expect_equal(class(x), "Date")

  x <- utils_coerce_time_class(
    x = c("2024-01-01", "2024-02-01"),
    to = "POSIXct"
  )
  expect_true("POSIXct" %in% class(x))


  x <- utils_coerce_time_class(
    x = c("2024-01-01", "2024-02-01"),
    to = "numeric"
  )
  expect_equal(class(x), "numeric")

})

Try the distantia package in your browser

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

distantia documentation built on April 4, 2025, 5:42 a.m.