diff +blockmatrix/toMatrixTest.m @ 820:501750fbbfdb

Merge with feature/grids
author Jonatan Werpers <jonatan@werpers.com>
date Fri, 07 Sep 2018 14:40:58 +0200
parents a5f1b0267dba
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/+blockmatrix/toMatrixTest.m	Fri Sep 07 14:40:58 2018 +0200
@@ -0,0 +1,78 @@
+function tests = toMatrixTest()
+    tests = functiontests(localfunctions);
+end
+
+function testError(testCase)
+    testCase.verifyError(@()blockmatrix.toMatrix([]), 'blockmatrix:toMatrix:NotABlockmatrix')
+end
+
+function testToMatrix(testCase)
+    cases = {
+        {
+            {},
+            [],
+        },
+        {
+            {1, 2; 3, 4},
+            [1,2; 3,4],
+        }
+        {
+            {
+            [2 2; 2 1], [1; 2];
+            [2 2], [1]
+            },
+            [2 2 1;
+             2 1 2;
+             2 2 1],
+        },
+        {
+            {
+            [2 2; 2 1], [];
+            [2 2], [1]
+            },
+            [2 2 0;
+             2 1 0;
+             2 2 1],
+        },
+        {
+            {
+            [2 2; 2 1], [];
+            [2 2], []
+            },
+            [2 2;
+             2 1;
+             2 2],
+        },
+        {
+            {
+            [2 2; 2 1], [1; 2];
+            [], []
+            },
+            [2 2 1;
+             2 1 2],
+        },
+        {
+            {zeros(0,0)},
+            [],
+        },
+        {
+            {zeros(3,0), zeros(3,0)},
+            zeros(3,0),
+        },
+        {
+            {zeros(3,0); zeros(2,0)},
+            zeros(5,0),
+        },
+        {
+            {zeros(0,3), zeros(0,2)},
+            zeros(0,5),
+        },
+    };
+
+    for i = 1:length(cases)
+        in = cases{i}{1};
+        out = full(blockmatrix.toMatrix(in));
+        expected = cases{i}{2};
+        testCase.verifyEqual(out, expected);
+    end
+end