Mercurial > repos > public > sbplib
comparison +grid/equidistantTest.m @ 154:c7b2f645101f feature/grids
Added classes and functions for Cartesian and equidistant grids.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 18 Feb 2016 16:46:02 +0100 |
parents | |
children | 4f935415700e |
comparison
equal
deleted
inserted
replaced
153:7aee9eba3bb8 | 154:c7b2f645101f |
---|---|
1 function tests = equidistantTest() | |
2 tests = functiontests(localfunctions); | |
3 end | |
4 | |
5 | |
6 function testErrorInvalidLimits(testCase) | |
7 in = { | |
8 {10,{1}}, | |
9 {10,[0,1]}, | |
10 {[10,10],{0,1},{1}}, | |
11 {[10,10],{1},{1,0}}, | |
12 {10,{1,0}}, | |
13 {[10, 5],{1,0}, {0,-1}}, | |
14 }; | |
15 | |
16 for i = 1:length(in) | |
17 testCase.verifyError(@()grid.equidistant(in{i}{:}),'grid:equidistant:InvalidLimits',sprintf('in(%d) = %s',i,toString(in{i}))); | |
18 end | |
19 end | |
20 | |
21 function testErrorNonMatchingParam(testCase) | |
22 in = { | |
23 {[],{1}}, | |
24 {[],{1},{0,1}}, | |
25 {[5,5],{0,1},{0,1},{0,1}}, | |
26 {[5,5,4],{0,1},{0,1}}, | |
27 }; | |
28 | |
29 for i = 1:length(in) | |
30 testCase.verifyError(@()grid.equidistant(in{i}{:}),'grid:equidistant:NonMatchingParameters',sprintf('in(%d) = %s',i,toString(in{i}))); | |
31 end | |
32 end | |
33 | |
34 | |
35 function testCompiles(testCase) | |
36 in = { | |
37 {5, {0,1}}, | |
38 {[3 3],{0,1},{0,2}}, | |
39 }; | |
40 | |
41 out = { | |
42 [[0; 0.25; 0.5; 0.75; 1]], | |
43 [[0; 0; 0; 0.5; 0.5; 0.5; 1; 1; 1;],[0; 1; 2; 0; 1; 2; 0; 1; 2;]], | |
44 }; | |
45 | |
46 for i = 1:length(in) | |
47 g = grid.equidistant(in{i}{:}); | |
48 testCase.verifyEqual(g.points(),out{i}); | |
49 end | |
50 end |