comparison +blockmatrix/isBlockmatrixTest.m @ 427:a613960a157b feature/quantumTriangles

merged with feature/beams
author Ylva Rydin <ylva.rydin@telia.com>
date Thu, 26 Jan 2017 15:59:25 +0100
parents f0f4ca946068
children
comparison
equal deleted inserted replaced
426:29944ea7674b 427:a613960a157b
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 blockmatrix.zero({[1 2 3],[2 3]}),
57 true % A zero block matrix is a block matrix
58 },
59 };
60
61 for i = 1:length(cases)
62 in = cases{i}{1};
63 out = blockmatrix.isBlockmatrix(in);
64 expected = cases{i}{2};
65 testCase.verifyEqual(out, expected, sprintf('Should return %d for %s', expected, toString(in)));
66 end
67 end