Mercurial > repos > public > sbplib
comparison +grid/CurvilinearTest.m @ 170:62b5f3c34bcb feature/grids
Implemented Curvilinear and equdistantCurvilinear.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 25 Feb 2016 11:10:25 +0100 |
parents | |
children | f7bb2a94d291 |
comparison
equal
deleted
inserted
replaced
169:ba8adcaf4681 | 170:62b5f3c34bcb |
---|---|
1 function tests = CurvilinearTest() | |
2 tests = functiontests(localfunctions); | |
3 end | |
4 | |
5 function testMappingInputGridFunction(testCase) | |
6 in = { | |
7 {{1:10}, @(x) exp(x)}, | |
8 {{1:10,1:6}, @(x,y) [exp(x+y); exp(x-y)]}, | |
9 {{1:10,1:5,1:7}, @(x,y,z)[exp(x+y+z); exp(x-y-z); 2+x+y-z]}, | |
10 }; | |
11 | |
12 out = { | |
13 [10, 1]; | |
14 [10*6, 2]; | |
15 [10*5*7, 3]; | |
16 }; | |
17 | |
18 | |
19 % How to test this? Just make sure it runs without errors. | |
20 | |
21 for i = 1:length(in) | |
22 g = grid.Curvilinear(in{i}{2},in{i}{1}{:}); | |
23 testCase.verifyEqual(size(g.coords),out{i}); | |
24 end | |
25 end | |
26 | |
27 function testMappingInputComponentMatrix(testCase) | |
28 in = { | |
29 {{1:3}, [1 2 3]'}, | |
30 {{1:2, 1:3}, [1 2 3 4 5 6; 7 8 9 10 11 12]'}, | |
31 }; | |
32 | |
33 for i = 1:length(in) | |
34 g = grid.Curvilinear(in{i}{2},in{i}{1}{:}); | |
35 testCase.verifyEqual(g.coords,in{i}{2}); | |
36 end | |
37 end | |
38 | |
39 function testMappingInputCellOfMatrix(testCase) | |
40 | |
41 in = { | |
42 {{1:3}, {[1 2 3]'}}, | |
43 {{1:2, 1:3}, {[1 2 3; 4 5 6], [7 8 9; 10 11 12]}}, | |
44 }; | |
45 | |
46 out = { | |
47 [1 2 3]', | |
48 [1 2 3 4 5 6; 7 8 9 10 11 12]', | |
49 }; | |
50 | |
51 for i = 1:length(in) | |
52 g = grid.Curvilinear(in{i}{2},in{i}{1}{:}); | |
53 testCase.verifyEqual(g.coords,out{i}); | |
54 end | |
55 end | |
56 | |
57 function testMappingInputCellOfVectors(testCase) | |
58 in = { | |
59 {{1:3}, {[1 2 3]'}}, | |
60 {{1:2, 1:3}, {[1 2 3 4 5 6]', [7 8 9 10 11 12]'}}, | |
61 }; | |
62 | |
63 out = { | |
64 [1 2 3]', | |
65 [1 2 3 4 5 6; 7 8 9 10 11 12]', | |
66 }; | |
67 end | |
68 | |
69 function testMappingInputError(testCase) | |
70 testCase.assumeFail(); | |
71 end |