Skip to content

Commit

Permalink
Test chunking.
Browse files Browse the repository at this point in the history
  • Loading branch information
kondziu committed Jul 22, 2021
1 parent 81df193 commit 97d1804
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
4 changes: 3 additions & 1 deletion ufos/src/ufos.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ SEXP ufo_initialize() {
void __validate_status_or_die (int status) {
switch(status) {
case 0: return;
default:
default: {
// Print message for %i that depends on %i
Rf_error("Could not create UFO (%i)", status);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion ufovectors/tests/testthat/test-assign.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
context("UFO vector in place mutation")
context("UFO vector assignment")

test_ufo_assign <- function (data, subscript, ufo_constructor) {
new_data_length <- length(data[subscript])
Expand Down
24 changes: 24 additions & 0 deletions ufovectors/tests/testthat/test-chunking.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
context("Vector ufo apply")

test_apply <- function (f, ..., chunk_size) {
ufo_result <- ufo_apply(FUN=f, ..., chunk_size=chunk_size)
reference_result <- mapply(FUN=f, ..., SIMPLIFY=TRUE)
expect_equal(ufo_result, reference_result)
expect_equal(is_ufo(ufo_result), TRUE)
}

test_that("ufo_apply 1 input tiny chunks", test_apply(function(x) x + 1, 1:10000, chunk_size=1))
test_that("ufo_apply 2 inputs tiny chunks", test_apply(function(x, y) x + y + 1, 1:10000, 1:1000, chunk_size=1))
test_that("ufo_apply 3 inputs tiny chunks", test_apply(function(x, y, z) x + y + z + 1, 1:10000, 1:1000, 1:100, chunk_size=1))
test_that("ufo_apply 1 input small chunks", test_apply(function(x) x + 1, 1:10000, chunk_size=100))
test_that("ufo_apply 2 inputs small chunks", test_apply(function(x, y) x + y + 1, 1:10000, 1:1000, chunk_size=100))
test_that("ufo_apply 3 inputs small chunks", test_apply(function(x, y, z) x + y + z + 1, 1:10000, 1:1000, 1:100, chunk_size=100))
test_that("ufo_apply 1 input medium chunks", test_apply(function(x) x + 1, 1:10000, chunk_size=1000))
test_that("ufo_apply 2 inputs medium chunks", test_apply(function(x, y) x + y + 1, 1:10000, 1:1000, chunk_size=1000))
test_that("ufo_apply 3 inputs medium chunks", test_apply(function(x, y, z) x + y + z + 1, 1:10000, 1:1000, 1:100, chunk_size=1000))
test_that("ufo_apply 1 input big chunks", test_apply(function(x) x + 1, 1:10000, chunk_size=10000))
test_that("ufo_apply 2 inputs big chunks", test_apply(function(x, y) x + y + 1, 1:10000, 1:1000, chunk_size=10000))
test_that("ufo_apply 3 inputs big chunks", test_apply(function(x, y, z) x + y + z + 1, 1:10000, 1:1000, 1:100, chunk_size=10000))
test_that("ufo_apply 1 input hugenormous chunks", test_apply(function(x) x + 1, 1:10000, chunk_size=100000))
test_that("ufo_apply 2 inputs hugenormous chunks", test_apply(function(x, y) x + y + 1, 1:10000, 1:1000, chunk_size=100000))
test_that("ufo_apply 3 inputs hugenormous chunks", test_apply(function(x, y, z) x + y + z + 1, 1:10000, 1:1000, 1:100, chunk_size=100000))

0 comments on commit 97d1804

Please sign in to comment.