Skip to content

Commit 1116f40

Browse files
committed
Added testing framework with some tests.
1 parent 7583f8f commit 1116f40

File tree

6 files changed

+260
-0
lines changed

6 files changed

+260
-0
lines changed

+sctool/runTests.m

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function result = runTests
2+
3+
import matlab.unittest.TestSuite;
4+
5+
dirname = which('lapsolve');
6+
[pathstr,fname,fext] = fileparts(dirname);
7+
dirname = fullfile(pathstr,'tests');
8+
suiteClass = TestSuite.fromFolder(dirname);
9+
result = run(suiteClass);
10+
11+
end

tests/testDisk.m

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
classdef testDisk < matlab.unittest.TestCase
2+
3+
properties
4+
map
5+
end
6+
7+
8+
% methods(TestMethodSetup)
9+
% function createFigure(testCase)
10+
% end
11+
% end
12+
%
13+
% methods(TestMethodTeardown)
14+
% end
15+
16+
methods (TestClassSetup)
17+
function createMap(testCase)
18+
opt = sctool.scmapopt('trace',0,'tol',1e-12);
19+
p = polygon([4 2i -2+4i -3 -3-1i 2-2i]);
20+
testCase.map = diskmap(p,opt);
21+
end
22+
end
23+
24+
methods (Test)
25+
26+
function testForwardMap(testCase)
27+
result = testCase.map([0.5+0.5i -0.9 -0.8+0.3i (1+1i)/sqrt(2)]);
28+
expected = [
29+
-2.301479291389453 + 0.891455618349974i,...
30+
-2.959017053517382 - 0.004724964608807i,...
31+
-2.920229222824237 + 0.110570172682907i,...
32+
-2.699042997340806 + 1.203828010636846i,...
33+
];
34+
testCase.verifyEqual(result,expected,'abstol',1e-10);
35+
end
36+
37+
function testInverseMap(testCase)
38+
val = testCase.map([0.5+0.5i -0.9 -0.8+0.3i (1+1i)/sqrt(2)]);
39+
result = evalinv( testCase.map, val );
40+
expected = [0.5+0.5i -0.9 -0.8+0.3i (1+1i)/sqrt(2)];
41+
testCase.verifyEqual(result,expected,'abstol',1e-10);
42+
end
43+
44+
function testCenter(testCase)
45+
f = center(testCase.map,0);
46+
result = f(0);
47+
testCase.verifyEqual(result,0,'abstol',1e-11);
48+
end
49+
50+
function testPlot(testCase)
51+
fig = figure;
52+
plot(testCase.map,4,3)
53+
close(fig)
54+
end
55+
56+
end
57+
58+
59+
60+
end

tests/testExterior.m

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
classdef testExterior < matlab.unittest.TestCase
2+
3+
properties
4+
map
5+
end
6+
7+
8+
% methods(TestMethodSetup)
9+
% function createFigure(testCase)
10+
% end
11+
% end
12+
%
13+
% methods(TestMethodTeardown)
14+
% end
15+
16+
methods (TestClassSetup)
17+
function createMap(testCase)
18+
opt = sctool.scmapopt('trace',0,'tol',1e-12);
19+
p = polygon([4 2i -2+4i -3 -3-1i 2-2i]);
20+
testCase.map = extermap(p,opt);
21+
end
22+
end
23+
24+
methods (Test)
25+
26+
function testForwardMap(testCase)
27+
result = testCase.map([0.5+0.5i -0.9 -0.8+0.3i (1+1i)/sqrt(2)]).';
28+
expected = [
29+
3.383320944105799 - 2.338017988574543i
30+
-3.257095120413423 + 0.536117032603197i
31+
-3.428512520416633 - 0.641446812228358i
32+
2.571844815094428 - 1.428155184905573i
33+
];
34+
testCase.verifyEqual(result,expected,'abstol',1e-10);
35+
end
36+
37+
function testInverseMap(testCase)
38+
val = testCase.map([0.5+0.5i -0.9 -0.8+0.3i (1+1i)/sqrt(2)]);
39+
result = evalinv( testCase.map, val );
40+
expected = [0.5+0.5i -0.9 -0.8+0.3i (1+1i)/sqrt(2)];
41+
testCase.verifyEqual(result,expected,'abstol',1e-10);
42+
end
43+
44+
function testPlot(testCase)
45+
fig = figure;
46+
plot(testCase.map,4,3)
47+
close(fig)
48+
end
49+
50+
end
51+
52+
53+
54+
end

tests/testHalfplane.m

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
classdef testHalfplane < matlab.unittest.TestCase
2+
3+
properties
4+
map
5+
end
6+
7+
methods (TestClassSetup)
8+
function createMap(testCase)
9+
opt = sctool.scmapopt('trace',0,'tol',1e-12);
10+
p = polygon([4 2i -2+4i -3 -3-1i 2-2i]);
11+
testCase.map = hplmap(p,opt);
12+
end
13+
end
14+
15+
methods (Test)
16+
17+
function testForwardMap(testCase)
18+
result = testCase.map([-1+0.01i 2i 4+0.5i Inf]);
19+
expected = [
20+
3.718839996085665 - 0.046084791699413i,...
21+
1.734612962216089 - 0.777136490010106i,...
22+
1.179285609480821 - 1.753573737693204i,...
23+
2.000000000000000 - 2.000000000000000i,...
24+
];
25+
testCase.verifyEqual(result,expected,'abstol',1e-10);
26+
end
27+
28+
function testInverseMap(testCase)
29+
val = testCase.map([-1 -1+0.01i 2i 4+0.5i]);
30+
result = evalinv( testCase.map, val );
31+
expected = [ -1 -1+0.01i 2i 4+0.5i ];
32+
testCase.verifyEqual(result,expected,'abstol',1e-10);
33+
end
34+
35+
function testPlot(testCase)
36+
fig = figure;
37+
plot(testCase.map,2,3)
38+
close(fig)
39+
end
40+
41+
end
42+
43+
44+
45+
end

tests/testRectangle.m

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
classdef testRectangle < matlab.unittest.TestCase
2+
3+
properties
4+
map
5+
end
6+
7+
methods (TestClassSetup)
8+
function createMap(testCase)
9+
opt = sctool.scmapopt('trace',0,'tol',1e-12);
10+
p = polygon([4 2i -2+4i -3 -3-1i 2-2i]);
11+
testCase.map = rectmap(p,1:4,opt);
12+
end
13+
end
14+
15+
methods (Test)
16+
17+
function testForwardMap(testCase)
18+
result = testCase.map([1.5 1.4+3i -0.6+1i 1].');
19+
expected = [
20+
3.641550444027862 - 0.358449555972138i
21+
-0.005336970451055 + 1.988135598448822i
22+
-1.643459212104280 + 0.428597577267735i
23+
1.646072527976422 - 1.929214505595285i
24+
];
25+
testCase.verifyEqual(result,expected,'abstol',1e-7);
26+
end
27+
28+
function testInverseMap(testCase)
29+
val = testCase.map([1.5 1.4+3i -0.6+1i 1]);
30+
result = evalinv( testCase.map, val );
31+
expected = [1.5 1.4+3i -0.6+1i 1];
32+
testCase.verifyEqual(result,expected,'abstol',1e-7);
33+
end
34+
35+
function testPlot(testCase)
36+
fig = figure;
37+
plot(testCase.map,4,3)
38+
close(fig)
39+
end
40+
41+
end
42+
43+
44+
45+
end

tests/testStrip.m

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
classdef testStrip < matlab.unittest.TestCase
2+
3+
properties
4+
map
5+
end
6+
7+
methods (TestClassSetup)
8+
function createMap(testCase)
9+
opt = sctool.scmapopt('trace',0,'tol',1e-12);
10+
p = polygon([4 2i -2+4i -3 -3-1i 2-2i]);
11+
testCase.map = stripmap(p,[1 4],opt);
12+
end
13+
end
14+
15+
methods (Test)
16+
17+
function testForwardMap(testCase)
18+
result = testCase.map([1+1i Inf -2+0.5i 0].');
19+
expected = [
20+
-3.000000000000000 - 0.312856946533931i
21+
-3.000000000000000 + 0.000000000000000i
22+
3.534971699300866 - 0.074755569347609i
23+
0.000000000000000 + 2.000000000000000i
24+
];
25+
testCase.verifyEqual(result,expected,'abstol',1e-10);
26+
end
27+
28+
function testInverseMap(testCase)
29+
val = testCase.map([4 -2+0.5i 1+0.5i]);
30+
result = evalinv( testCase.map, val );
31+
expected = [4 -2+0.5i 1+0.5i];
32+
testCase.verifyEqual(result,expected,'abstol',1e-10);
33+
end
34+
35+
function testPlot(testCase)
36+
fig = figure;
37+
plot(testCase.map,4,3)
38+
close(fig)
39+
end
40+
41+
end
42+
43+
44+
45+
end

0 commit comments

Comments
 (0)