forked from ZachL1/Bilibili-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tests_WeatherEvents.m
52 lines (40 loc) · 1.23 KB
/
Tests_WeatherEvents.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
function tests = Tests_WeatherEvents
% Tests for weather event prediction application
%
% Copyright 2020 The MathWorks, Inc.
tests = functiontests(localfunctions);
end
function testDefaultDate(testCase)
% Test with default date
eventtype = "Wildfire";
location = "VERMONT";
damage = predictStormDamage(location,eventtype,1);
% The output of the function is the damage cost
verifySize(testCase,damage,[1,1]);
end
function testDateInput(testCase)
% Test with non-default date
eventtype = "Tornado";
location = "MASSACHUSETTS";
date = datetime(2020,8,21);
damage = predictStormDamage(location,eventtype,1,date);
% The output of the function is the damage cost
verifyClass(testCase,damage,"double");
end
function testInputDataType(testCase)
% Test with lowercase char
eventtype = "Wildfire";
location = 'new york';
damage = predictStormDamage(location,eventtype,1);
% The output of the function is the damage cost
verifySize(testCase,damage,[1,1]);
end
function testModelOutput(testCase)
% Test model prediction is reasonable
eventtype = "Tornado";
location = "Ohio";
date = datetime(2020,8,21);
damage = predictStormDamage(location,eventtype,1,date);
% Test that the model predicts a postive value
verifyGreaterThanOrEqual(testCase,damage,0);
end