Mercurial > repos > public > sbplib
comparison +blockmatrix/getDivisionTest.m @ 205:f0ef314e2070 feature/grids
blockmatrix: added function to calculate the block division for a given blockmatrix.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 15 Jun 2016 16:28:22 +0200 |
parents | |
children | a5f1b0267dba |
comparison
equal
deleted
inserted
replaced
204:4ce0af75d2f4 | 205:f0ef314e2070 |
---|---|
1 function tests = getDivisionTest() | |
2 tests = functiontests(localfunctions); | |
3 end | |
4 | |
5 function testError(testCase) | |
6 cases = { | |
7 magic(3), | |
8 {[2 2 2];{1,2}}, | |
9 {[2 2 2];[1 2]}, | |
10 {[2; 2; 2], [1; 2]}, | |
11 }; | |
12 | |
13 for i =1:length(cases) | |
14 testCase.verifyError(@()blockmatrix.getDivision(cases{i}), 'blockmatrix:getDivision:NotABlockmatrix') | |
15 end | |
16 end | |
17 | |
18 function testGetDivision(testCase) | |
19 cases = { | |
20 { | |
21 {}, | |
22 {[],[]}; | |
23 }, | |
24 { | |
25 { | |
26 [2 2; 2 1], [1; 2]; | |
27 [2 2], [1] | |
28 }, | |
29 {[2 1], [2 1]} | |
30 }, | |
31 { | |
32 { | |
33 [2 2; 2 1], []; | |
34 [2 2], [1] | |
35 }, | |
36 {[2 1], [2 1]} | |
37 }, | |
38 { | |
39 { | |
40 [2 2; 2 1], []; | |
41 [2 2], [] | |
42 }, | |
43 {[2 1], [2 0]} | |
44 }, | |
45 { | |
46 { | |
47 [2 2; 2 1], [1; 2]; | |
48 [], [] | |
49 }, | |
50 {[2 0], [2 1]} | |
51 }, | |
52 { | |
53 { | |
54 [2 2; 2 1]; | |
55 [2 2] | |
56 }, | |
57 {[2 1], 2} | |
58 }, | |
59 }; | |
60 | |
61 for i = 1:length(cases) | |
62 in = cases{i}{1}; | |
63 out = blockmatrix.getDivision(in); | |
64 expected = cases{i}{2}; | |
65 testCase.verifyEqual(out, expected); | |
66 end | |
67 end | |
68 | |
69 |