tests/testthat/test-function-resetTimePart.R

#
# This test file has been generated by kwb.test::create_test_files()
#

test_that("resetTimePart() works", {

  kwb.datetime:::resetTimePart(tstamp = as.POSIXct("2018-06-03 23:50:00"), resetHour = 1)
   kwb.datetime:::resetTimePart(tstamp = as.POSIXct("2018-06-03 23:50:00"), resetHour = 1:2)
   kwb.datetime:::resetTimePart(tstamp = as.POSIXct("2018-06-03 23:50:00"), resetHour = "a")
   kwb.datetime:::resetTimePart(tstamp = as.POSIXct("2018-06-03 23:50:00"), resetHour = c("a", "b"))
   kwb.datetime:::resetTimePart(tstamp = as.POSIXct("2018-06-03 23:50:00"), resetHour = TRUE)
   kwb.datetime:::resetTimePart(tstamp = as.POSIXct("2018-06-03 23:50:00"), resetHour = FALSE)
   expect_error(
    kwb.datetime:::resetTimePart(tstamp = 1, resetHour = 1)
    # invalid 'trim' argument
  )
   expect_error(
    kwb.datetime:::resetTimePart(tstamp = 1, resetHour = as.POSIXct("2018-06-03 23:50:00"))
    # 'any' not defined for "POSIXt" objects
  )
   expect_error(
    kwb.datetime:::resetTimePart(tstamp = 1, resetHour = list(key = c("a", "b"), value = 1:2))
    # (list) object cannot be coerced to type 'logical'
  )

})
KWB-R/kwb.datetime documentation built on July 9, 2021, 10:28 p.m.