Mercurial > repos > public > sbplib
comparison sparse2cellTest.m @ 200:ef41fde95ac4 feature/beams
Merged feature/grids into feature/beams.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Mon, 13 Jun 2016 16:59:02 +0200 |
parents | 770da87a6dc4 |
children |
comparison
equal
deleted
inserted
replaced
181:419ec303e97d | 200:ef41fde95ac4 |
---|---|
1 function tests = sparse2cellTest() | |
2 tests = functiontests(localfunctions); | |
3 end | |
4 | |
5 function testErrorNonMatchingDim(testCase) | |
6 in = { | |
7 {magic(5), [1 2 3], [4]}, | |
8 {magic(5), [1 1 1 1 1 1], [5]}, | |
9 {magic(5), [5], [1 1 1 1 1 1]}, | |
10 {ones(4,2),[2 3],[2]}, | |
11 {ones(4,2),[2 2],[3]}, | |
12 }; | |
13 | |
14 for i = 1:length(in) | |
15 testCase.verifyError(@()sparse2cell(in{i}{:}),'sparse2cell:NonMatchingDim'); | |
16 end | |
17 end | |
18 | |
19 function testOutput(testCase) | |
20 in = {}; | |
21 out = {}; | |
22 in{1}{1} =[17 24 1 8 15; 23 5 7 14 16; 4 6 13 20 22; 10 12 19 21 3; 11 18 25 2 9]; | |
23 in{1}{2} = [1 4]; | |
24 in{1}{3} = [2 3]; | |
25 | |
26 out{1} = { | |
27 [17 24], [1 8 15]; | |
28 [23 5; 4 6; 10 12; 11 18], [7 14 16; 13 20 22; 19 21 3; 25 2 9]; | |
29 }; | |
30 | |
31 in{1}{1} = [17 24 1 8 15; 23 5 0 0 0; 4 6 0 0 0; 10 12 0 0 0; 11 18 0 0 0]; | |
32 in{1}{2} = [1 4]; | |
33 in{1}{3} = [2 3]; | |
34 | |
35 out{1} = { | |
36 [17 24], [1 8 15]; | |
37 [23 5; 4 6; 10 12; 11 18], []; | |
38 }; | |
39 | |
40 for i = 1:length(in) | |
41 testCase.verifyEqual(sparse2cell(in{i}{:}), out{i}); | |
42 end | |
43 end |