This repository has been archived by the owner on Sep 14, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.m
62 lines (50 loc) · 2.21 KB
/
test.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
classdef test < matlab.unittest.TestCase
%Test your challenge solution here using matlab unit tests
%
% Check if your main file 'challenge.m', 'disparity_map.m' and
% verify_dmap.m do not use any toolboxes.
%
% Check if all your required variables are set after executing
% the file 'challenge.m'
% properties
% end
methods (Test)
function check_variables(testCase)
challenge;
% check group_number
testCase.verifyNotEmpty(group_number);
testCase.verifyGreaterThan(group_number, 0);
testCase.verifyNotEmpty(members);
% check members and mail
testCase.verifyGreaterThan(length(members), 0);
testCase.verifyEqual(length(members), length(mail));
% check D, R, T, p, elapsed_time;
testCase.verifyNotEmpty(D);
testCase.verifyTrue(sum(D > 0,'all') > 0);
testCase.verifyNotEmpty(R);
testCase.verifyTrue(sum(R > 0,'all') > 0);
testCase.verifyNotEmpty(T);
testCase.verifyTrue(sum(T > 0,'all') > 0);
testCase.verifyNotEmpty(p);
testCase.verifyTrue(p > 0);
testCase.verifyNotEmpty(elapsed_time);
testCase.verify(elapsed_time > 0);
end
function check_toolboxes(testCase)
[~,pList1] = matlab.codetools.requiredFilesAndProducts('verify_dmap.m');
[~,pList2] = matlab.codetools.requiredFilesAndProducts('disparity_map.m');
[~,pList3] = matlab.codetools.requiredFilesAndProducts('verify_dmap.m');
actOut = [length(pList1), length(pList2), length(pList3)];
expOut = [1, 1, 1];
testCase.verifyEqual(actOut,expOut);
end
function check_psnr(testCase)
A = uint8(randi(255, 200, 300));
ref = uint8(randi(255, 200, 300));
actOut = verify_dmap(A, ref);
expOut = psnr(A, ref);
tol = 1e-8;
testCase.verifyLessThan(sum(abs(actOut-expOut), 'all'),tol);
end
end
end