From d8df7fcb9ec9161ebca569ac426ac8aae9ebe0e3 Mon Sep 17 00:00:00 2001 From: Waldir Leoncio Date: Tue, 25 Feb 2020 11:48:40 +0100 Subject: [PATCH] Added tests --- tests/testthat/test-convertedBaseFunctions.R | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/testthat/test-convertedBaseFunctions.R b/tests/testthat/test-convertedBaseFunctions.R index f4bf346..6ef25ba 100644 --- a/tests/testthat/test-convertedBaseFunctions.R +++ b/tests/testthat/test-convertedBaseFunctions.R @@ -84,4 +84,15 @@ test_that("size works as on MATLAB", { expect_equal(size(mx, 2), 3) expect_equal(size(ra, 2), 3) 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))) }) \ No newline at end of file