tests/testthat/test-function-roundTime.R

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

test_that("roundTime() works", {

  kwb.datetime:::roundTime(tstamp = 1, tstep = 1)
   kwb.datetime:::roundTime(tstamp = 1, tstep = 1:2)
   kwb.datetime:::roundTime(tstamp = 1, tstep = TRUE)
   kwb.datetime:::roundTime(tstamp = 1, tstep = FALSE)
   kwb.datetime:::roundTime(tstamp = 1:2, tstep = 1)
   kwb.datetime:::roundTime(tstamp = 1:2, tstep = 1:2)
   kwb.datetime:::roundTime(tstamp = 1:2, tstep = TRUE)
   kwb.datetime:::roundTime(tstamp = TRUE, tstep = 1)
   kwb.datetime:::roundTime(tstamp = TRUE, tstep = 1:2)
   kwb.datetime:::roundTime(tstamp = TRUE, tstep = TRUE)
   kwb.datetime:::roundTime(tstamp = TRUE, tstep = FALSE)
   kwb.datetime:::roundTime(tstamp = FALSE, tstep = 1)
   kwb.datetime:::roundTime(tstamp = FALSE, tstep = 1:2)
   kwb.datetime:::roundTime(tstamp = FALSE, tstep = TRUE)
   kwb.datetime:::roundTime(tstamp = FALSE, tstep = FALSE)
   kwb.datetime:::roundTime(tstamp = as.POSIXct("2018-06-03 23:50:00"), tstep = 1)
   kwb.datetime:::roundTime(tstamp = as.POSIXct("2018-06-03 23:50:00"), tstep = 1:2)
   kwb.datetime:::roundTime(tstamp = as.POSIXct("2018-06-03 23:50:00"), tstep = TRUE)
   kwb.datetime:::roundTime(tstamp = as.POSIXct("2018-06-03 23:50:00"), tstep = FALSE)
   expect_error(
    kwb.datetime:::roundTime(tstamp = 1, tstep = "a")
    # non-numeric argument to binary operator
  )
   expect_error(
    kwb.datetime:::roundTime(tstamp = 1, tstep = as.POSIXct("2018-06-03 23:50:00"))
    # '%%' not defined for "POSIXt" objects
  )
   expect_error(
    kwb.datetime:::roundTime(tstamp = 1:2, tstep = FALSE)
    # NAs are not allowed in subscripted assignments
  )
   expect_error(
    kwb.datetime:::roundTime(tstamp = list(key = c("a", "b"), value = 1:2), tstep = 1)
    # (list) object cannot be coerced to type 'integer'
  )

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