Skip to content

Commit

Permalink
proper tests for cube, related to #3179
Browse files Browse the repository at this point in the history
  • Loading branch information
jangorecki committed Dec 5, 2018
1 parent a3dafe3 commit 7a2a5a3
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -10332,25 +10332,27 @@ test(1750.32,
groupingsets(dt, j = c(list(cnt=.N), lapply(.SD, sum)), by = c("year","status"), .SDcols=c("amount","value"), sets=sets, id=TRUE)
)
# cube
sets = local({
by=c("color","year","status")
n = length(by)
keepBool = sapply(2L^(1:n - 1L), function(k) rep(c(FALSE, TRUE), each=((2L^n)/(2L*k)), times=k))
lapply((2L^n):1, function(j) by[keepBool[j, ]])
})
test(1750.33,
cube(dt, j = c(list(cnt=.N), lapply(.SD, sum)), by = c("color","year","status"), id=TRUE),
groupingsets(dt, j = c(list(cnt=.N), lapply(.SD, sum)), by = c("color","year","status"), sets=sets, id=TRUE)
groupingsets(dt, j = c(list(cnt=.N), lapply(.SD, sum)), by = c("color","year","status"),
sets = list(c("color", "year", "status"),
c("color", "year"),
c("color", "status"),
"color",
c("year", "status"),
"year",
"status",
character(0)),
id = TRUE)
)
sets = local({
by=c("year","status")
n = length(by)
keepBool = sapply(2L^(1:n - 1L), function(k) rep(c(FALSE, TRUE), each=((2L^n)/(2L*k)), times=k))
lapply((2L^n):1, function(j) by[keepBool[j, ]])
})
test(1750.34,
cube(dt, j = c(list(cnt=.N), lapply(.SD, sum)), by = c("year","status"), .SDcols=c("amount","value"), id=TRUE),
groupingsets(dt, j = c(list(cnt=.N), lapply(.SD, sum)), by = c("year","status"), .SDcols=c("amount","value"), sets=sets, id=TRUE)
groupingsets(dt, j = c(list(cnt=.N), lapply(.SD, sum)), by = c("year","status"), .SDcols=c("amount","value"),
sets = list(c("year","status"),
"year",
"status",
character(0)),
id = TRUE)
)
# grouping sets with integer64
if (test_bit64) {
Expand Down

0 comments on commit 7a2a5a3

Please sign in to comment.