comparison +blockmatrix/getDivisionTest.m @ 886:8894e9c49e40 feature/timesteppers

Merge with default for latest changes
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Thu, 15 Nov 2018 16:36:21 -0800
parents a5f1b0267dba
children
comparison
equal deleted inserted replaced
816:b5e5b195da1e 886:8894e9c49e40
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 {zeros(3,0)},
61 {3, 0},
62 },
63 {
64 {zeros(3,0), zeros(3,0)},
65 {3, [0, 0]},
66 },
67 {
68 {zeros(3,0); zeros(2,0)},
69 {[3 2],0},
70 },
71 };
72
73 for i = 1:length(cases)
74 in = cases{i}{1};
75 out = blockmatrix.getDivision(in);
76 expected = cases{i}{2};
77 testCase.verifyEqual(out, expected);
78 end
79 end
80
81