-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMeanTest.m
67 lines (57 loc) · 2.16 KB
/
MeanTest.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
classdef MeanTest < 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
methods (TestClassSetup)
function createCube(testCase, width, height, nbands)
data = gallery('uniformdata', [height, width, nbands], 1);
% Suppress default value warnings for clearer test output
warning('off', 'Cube:DefaultQuantity');
warning('off', 'Cube:DefaultWavelengthUnit');
warning('off', 'Cube:DefaultWavelength');
warning('off', 'Cube:DefaultFWHM');
testCase.testCube = Cube(data);
% Turn warnings back on
warning('on', 'all');
end
end
methods (Test)
function meanResultWidth(testCase)
% Width should be 1 after taking the mean
m = testCase.testCube.mean;
testCase.verifyEqual(m.Width, 1);
end
function meanResultHeight(testCase)
% Height should be 1 after taking the mean
m = testCase.testCube.mean;
testCase.verifyEqual(m.Height, 1);
end
function meanPreservesBands(testCase)
% Number of bands should not change
nb = testCase.testCube.nBands;
m = testCase.testCube.mean;
testCase.verifyEqual(m.nBands, nb);
end
function meanIdempotent(testCase)
% mean twice should equal taking the mean once
once = testCase.testCube.mean.Data;
twice = testCase.testCube.mean.mean.Data;
testCase.verifyEqual(twice, once);
end
end
end