Skip to content

Commit

Permalink
improved a few funby tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gisler committed Jul 29, 2020
1 parent 082c3a3 commit 7557a3a
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions inst/tinytest/test_funby.R
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,11 @@ expect_identical(
)

expect_identical(
DTSg$new(CETtoDSTfractionalSecondData)$aggregate(by___H__, sum, ignoreDST = TRUE)$values(TRUE)[["value"]],
CETtoDSTfractionalSecondData[, .(value = sum(value)), by = "hour"][["value"]],
DTSg$new(CETtoDSTfractionalSecondData)$aggregate(by___H__, sum, ignoreDST = TRUE)$values(TRUE),
setkey(data.table(
.dateTime = as.POSIXct(c("2199-01-01 01:00:00", "2199-01-01 02:00:00"), tz = "Europe/Vienna"),
value = CETtoDSTfractionalSecondData[, .(value = sum(value)), by = "hour"][["value"]]
), ".dateTime"),
info = '"by___H__" works as expected (CETtoDST, multiplier == 1L)'
)

Expand Down Expand Up @@ -259,8 +262,11 @@ expect_identical(
)

expect_identical(
DTSg$new(CETfromDSTfractionalSecondData)$aggregate(by___H__, sum, ignoreDST = TRUE)$values(TRUE)[["value"]],
CETfromDSTfractionalSecondData[, .(value = sum(value)), by = "hour"][["value"]],
DTSg$new(CETfromDSTfractionalSecondData)$aggregate(by___H__, sum, ignoreDST = TRUE)$values(TRUE),
setkey(data.table(
.dateTime = as.POSIXct(c("2199-01-01 01:00:00", "2199-01-01 02:00:00", "2199-01-01 03:00:00"), tz = "Europe/Vienna"),
value = CETfromDSTfractionalSecondData[, .(value = sum(value)), by = "hour"][["value"]]
), ".dateTime"),
info = '"by___H__" works as expected (CETfromDST, multiplier == 1L)'
)

Expand Down Expand Up @@ -390,8 +396,11 @@ expect_identical(

#### base functions (CETtoFromDST, multiplier > 1L) ####
expect_identical(
DTSg$new(CEThourlyData)$aggregate(byY_____, sum, ignoreDST = TRUE, multiplier = 2L)$values(TRUE)[["value"]],
CEThourlyData[, .(value = sum(value)), by = .(year %/% 2L * 2L)][["value"]],
DTSg$new(CEThourlyData)$aggregate(byY_____, sum, ignoreDST = TRUE, multiplier = 2L)$values(TRUE),
setkey(data.table(
.dateTime = as.POSIXct(c("1998-01-01", "2000-01-01"), tz = "Europe/Vienna"),
value = CEThourlyData[, .(value = sum(value)), by = .(year %/% 2L * 2L)][["value"]]
), ".dateTime"),
info = '"byY_____" works as expected (CETtoFromDST, multiplier > 1L)'
)

Expand Down

0 comments on commit 7557a3a

Please sign in to comment.