|
1 |
| -# |
2 |
| -# Copyright (C) 2012 - 2013 Douglas Bates, Dirk Eddelbuettel and Romain Francois |
| 1 | + |
| 2 | +# Copyright (C) 2012 - 2022 Douglas Bates, Dirk Eddelbuettel and Romain Francois |
3 | 3 | #
|
4 | 4 | # This file is part of RcppEigen.
|
5 | 5 | #
|
@@ -85,3 +85,25 @@ integer_mat <- matrix(as.integer(diag(nrow = 5L)))
|
85 | 85 | numeric_mat <- diag(nrow = 5L)
|
86 | 86 | res <- as_Array2D(list(integer_mat, numeric_mat))
|
87 | 87 | expect_equal(unlist(res), rep.int(5, 6L))
|
| 88 | + |
| 89 | + |
| 90 | +## CI systems may have limited memory, and CRAN may not like us creating multi-gb objects |
| 91 | +## so remainer is opt-in |
| 92 | +if (Sys.getenv("RunLargeMemoryTests") != "yes") exit_file("Set 'RunLargeMemoryTests' to 'yes' to run.") |
| 93 | + |
| 94 | +## add test for wrapping of large vectors (PRs #105, 106) which works for vectors |
| 95 | +## but fails for matrices as we violate the 'size_t value permitted for lenth values |
| 96 | +## but not inside a `dim` object of type `integer` (aka `int32_t`) |
| 97 | +n <- 2^31 + 100 # in excess of limit of 2^31 - 1 |
| 98 | +res <- vector_large_wrap(n) |
| 99 | +expect_true(is.vector(res, "integer")) |
| 100 | +expect_equal(length(res), n) |
| 101 | +expect_equal(res[seq_len(2^10)], rep_len(0:9, 2^10)) |
| 102 | + |
| 103 | +expect_error(matrix_large_wrap(n)) |
| 104 | +n <- 2^31 - 100 # within limit of 2^31 - 1 for dim given one column |
| 105 | +res <- matrix_large_wrap(n) |
| 106 | +expect_true(is.matrix(res)) |
| 107 | +expect_equal(typeof(res), "integer") |
| 108 | +expect_equal(dim(res), c(n,1)) |
| 109 | +expect_equal(res[seq_len(2^10)], rep_len(0:9, 2^10)) |
0 commit comments