comparison +blockmatrix/isBlockmatrixTest.m @ 203:764438b52541 feature/grids

blockmatrix: Added functions to test for block matrcies and divisions.
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 15 Jun 2016 14:29:56 +0200
parents
children 4ce0af75d2f4
comparison
equal deleted inserted replaced
202:e2fefb6f0746 203:764438b52541
1 function tests = isBlockmatrixTest()
2 tests = functiontests(localfunctions);
3 end
4
5 function testIsBlockmatrix(testCase)
6 cases = {
7 {
8 magic(3),
9 false % Must be a cell array
10 }
11 {
12 {[2 2 2];{1,2}},
13 false % All elements of the cell matrix must be regular matrices
14 },
15 {
16 {[2 2 2];[1 2]},
17 false % Row dimensions must match
18 },
19 {
20 {[2; 2; 2], [1; 2]},
21 false % Column dimensions must match
22 },
23 {
24 {
25 [2 2; 2 1], [1; 2];
26 [2 2], [1]
27 },
28 true % A simple valid one
29 },
30 {
31 {
32 [2 2; 2 1], [];
33 [2 2], [1]
34 },
35 true % Empty blocks assumed to be zero and match dimensions
36 },
37 {
38 {
39 [2 2; 2 1], [];
40 [2 2], []
41 },
42 true % Empty blocks allowed.
43 },
44 {
45 {
46 [2 2; 2 1], [1; 2];
47 [], []
48 },
49 true % Empty blocks allowed.
50 },
51
52
53 };
54
55 for i = 1:length(cases)
56 in = cases{i}{1};
57 out = blockmatrix.isBlockmatrix(in);
58 expected = cases{i}{2};
59 testCase.verifyEqual(out, expected, sprintf('Should return %d for %s', expected, toString(in)));
60 end
61 end