Mercurial > repos > public > sbplib
comparison +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 |
comparison
equal
deleted
inserted
replaced
205:f0ef314e2070 | 206:50a323da7c7f |
---|---|
1 function tests = toMatrixTest() | |
2 tests = functiontests(localfunctions); | |
3 end | |
4 | |
5 function testError(testCase) | |
6 testCase.verifyError(@()blockmatrix.toMatrix([]), 'blockmatrix:toMatrix:NotABlockmatrix') | |
7 end | |
8 | |
9 function testToMatrix(testCase) | |
10 cases = { | |
11 { | |
12 {}, | |
13 [], | |
14 }, | |
15 { | |
16 {1, 2; 3, 4}, | |
17 [1,2; 3,4], | |
18 } | |
19 { | |
20 { | |
21 [2 2; 2 1], [1; 2]; | |
22 [2 2], [1] | |
23 }, | |
24 [2 2 1; | |
25 2 1 2; | |
26 2 2 1], | |
27 }, | |
28 { | |
29 { | |
30 [2 2; 2 1], []; | |
31 [2 2], [1] | |
32 }, | |
33 [2 2 0; | |
34 2 1 0; | |
35 2 2 1], | |
36 }, | |
37 { | |
38 { | |
39 [2 2; 2 1], []; | |
40 [2 2], [] | |
41 }, | |
42 [2 2; | |
43 2 1; | |
44 2 2], | |
45 }, | |
46 { | |
47 { | |
48 [2 2; 2 1], [1; 2]; | |
49 [], [] | |
50 }, | |
51 [2 2 1; | |
52 2 1 2], | |
53 }, | |
54 }; | |
55 | |
56 for i = 1:length(cases) | |
57 in = cases{i}{1}; | |
58 out = full(blockmatrix.toMatrix(in)); | |
59 expected = cases{i}{2}; | |
60 testCase.verifyEqual(out, expected); | |
61 end | |
62 end |