comparison +blockmatrix/isBlockmatrixTest.m @ 211:3c4ffbfbfb84 feature/beams

Merged feature/grid into feature/beams
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 16 Jun 2016 10:56:47 +0200
parents f0ef314e2070
children f0f4ca946068
comparison
equal deleted inserted replaced
200:ef41fde95ac4 211:3c4ffbfbfb84
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 true % An empty matrix is a matrix too
26 },
27 {
28 {
29 [2 2; 2 1], [1; 2];
30 [2 2], [1]
31 },
32 true % A simple valid one
33 },
34 {
35 {
36 [2 2; 2 1], [];
37 [2 2], [1]
38 },
39 true % Empty blocks assumed to be zero and match dimensions
40 },
41 {
42 {
43 [2 2; 2 1], [];
44 [2 2], []
45 },
46 true % Empty blocks allowed.
47 },
48 {
49 {
50 [2 2; 2 1], [1; 2];
51 [], []
52 },
53 true % Empty blocks allowed.
54 },
55 };
56
57 for i = 1:length(cases)
58 in = cases{i}{1};
59 out = blockmatrix.isBlockmatrix(in);
60 expected = cases{i}{2};
61 testCase.verifyEqual(out, expected, sprintf('Should return %d for %s', expected, toString(in)));
62 end
63 end