diff +blockmatrix/toMatrixTest.m @ 206:50a323da7c7f feature/grids

blockmatrix: Added function to convert blockmatrix to a regular matrix.
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 15 Jun 2016 16:31:24 +0200
parents
children a5f1b0267dba
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/+blockmatrix/toMatrixTest.m	Wed Jun 15 16:31:24 2016 +0200
@@ -0,0 +1,62 @@
+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],
+        },
+    };
+
+    for i = 1:length(cases)
+        in = cases{i}{1};
+        out = full(blockmatrix.toMatrix(in));
+        expected = cases{i}{2};
+        testCase.verifyEqual(out, expected);
+    end
+end