-
Notifications
You must be signed in to change notification settings - Fork 39
/
test-fromJSON-array.R
53 lines (42 loc) · 1.44 KB
/
test-fromJSON-array.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
test_that("fromJSON Array, row major", {
# test high dimensional arrays
lapply(2:5, function(n){
object <- array(1:prod(n), dim=1:n)
newobject <- fromJSON(toJSON(object));
expect_equal(object, newobject);
});
# adding some flat dimensions
lapply(1:5, function(n){
object <- array(1:prod(n), dim=c(1:n, 1))
newobject <- fromJSON(toJSON(object));
expect_equal(object, newobject);
});
});
test_that("fromJSON Array, column major", {
# test high dimensional arrays
lapply(2:5, function(n){
object <- array(1:prod(n), dim=1:n)
newobject <- fromJSON(toJSON(object, matrix="columnmajor"), columnmajor=TRUE);
expect_equal(object, newobject);
});
# adding some flat dimensions
lapply(1:5, function(n){
object <- array(1:prod(n), dim=c(1:n, 1))
newobject <- fromJSON(toJSON(object, matrix="columnmajor"), columnmajor=TRUE);
expect_equal(object, newobject);
});
});
test_that("fromJSON Array, character strings", {
# test high dimensional arrays
lapply(2:5, function(n){
object <- array(paste("cell", 1:prod(n)), dim=1:n)
newobject <- fromJSON(toJSON(object, matrix="columnmajor"), columnmajor=TRUE);
expect_equal(object, newobject);
});
# adding some flat dimensions
lapply(1:5, function(n){
object <- array(paste("cell", 1:prod(n)), dim=c(1:n, 1))
newobject <- fromJSON(toJSON(object, matrix="columnmajor"), columnmajor=TRUE);
expect_equal(object, newobject);
});
});