-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMapBandsTest.m
88 lines (71 loc) · 2.68 KB
/
MapBandsTest.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
classdef MapBandsTest < matlab.unittest.TestCase
properties
testCube
end
properties (ClassSetupParameter)
height = struct('row', 1, ...
'small', 3, ...
'large', 10 ...
)
width = struct('column', 1, ...
'small', 3, ...
'large', 10 ...
)
nbands = struct('single', 1, ...
'rgb', 3, ...
'multi', 5, ...
'hyper', 100 ...
);
end
properties (TestParameter)
% Valid functions to test
fs = struct('id', @(x) x, ...
'square', @(x) x.*x, ...
'neg', @(x) -x, ...
'flipY', @(x)flip(x,2), ...
'flipX', @(x)flip(x,1), ...
'constScalar', @(x) 1, ...
'constMatrix', @(x) ones(3,3) ...
);
end
methods (TestClassSetup)
function createCube(testCase, width, height, nbands)
data = gallery('uniformdata', [height, width, nbands], 1);
wls = gallery('uniformdata', [1, nbands], 1);
fwhms= gallery('uniformdata', [1, nbands], 2);
testCase.testCube = Cube(data, ...
'quantity', 'Testdata',...
'wlu', 'nm', 'wl', wls, 'fwhm', fwhms);
end
end
methods (Test)
function idMapBands(testCase)
% mapBands(id) should not change the data
id = @(x) x;
orig = testCase.testCube;
new = orig.mapBands(id);
testCase.verifyEqual(new.Data, orig.Data);
end
function defaultQuantity(testCase, fs)
% If no new quantity was supplied, result quantity should be
% 'Unknown'
orig = testCase.testCube;
new = orig.mapBands(fs);
testCase.verifyEqual(new.Quantity, 'Unknown');
end
function suppliedQuantity(testCase, fs)
% If a new quantity was supplied, result quantity should be
% set to the given value
orig = testCase.testCube;
qty = orig.Quantity;
new = orig.mapBands(fs, qty);
testCase.verifyEqual(new.Quantity, qty);
end
function bandNumber(testCase, fs)
% mapBands preserves nBands
orig = testCase.testCube;
new = orig.mapBands(fs);
testCase.verifyEqual(new.nBands, orig.nBands);
end
end
end