Added tests
This commit is contained in:
parent
240a3705e4
commit
d8df7fcb9e
1 changed files with 11 additions and 0 deletions
|
|
@ -84,4 +84,15 @@ test_that("size works as on MATLAB", {
|
||||||
expect_equal(size(mx, 2), 3)
|
expect_equal(size(mx, 2), 3)
|
||||||
expect_equal(size(ra, 2), 3)
|
expect_equal(size(ra, 2), 3)
|
||||||
expect_equal(size(ra, 3), 4)
|
expect_equal(size(ra, 3), 4)
|
||||||
|
})
|
||||||
|
|
||||||
|
test_that("reshape reshapes properly", {
|
||||||
|
mx <- matrix(1:4, 2)
|
||||||
|
ra <- array(1:12, c(2, 3, 2))
|
||||||
|
expect_equal(reshape(mx, c(1, 4)), matrix(1:4, 1))
|
||||||
|
expect_equal(reshape(mx, c(2, 2)), mx)
|
||||||
|
expect_equal(reshape(mx, c(1, 1, 4)), array(mx, c(1, 1, 4)))
|
||||||
|
expect_error(reshape(mx, c(1, 2, 3)))
|
||||||
|
expect_error(reshape(ra, c(1, 2, 3)))
|
||||||
|
expect_equal(reshape(ra, c(3, 2, 2)), array(ra, c(3, 2, 2)))
|
||||||
})
|
})
|
||||||
Loading…
Add table
Reference in a new issue