tests/testthat/test-splits.R

test_that("A split datetime components add up to its input value", {
  expect_true({
    x <- Sys.time()
    date <- get_date(x)
    time <- get_hour(x)
    date + time == x
  })
})

test_that("Center hour drives get_hour outcome", {
  expect_true({
    x <- as.POSIXct("2020-01-01 01:00 UTC", tz = "UTC")
    comparison <-
      get_hour(x, hour_center = +12) -
      get_hour(x, hour_center = -12)
    as.numeric(comparison) == 24*60*60
  })
})

test_that("StatHourglass doesn't throw an error", {
  expect_no_error({
    stat_hourglass()
  })
})

Try the gghourglass package in your browser

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

gghourglass documentation built on April 11, 2025, 5:53 p.m.