-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtests.cpp
More file actions
94 lines (77 loc) · 2.23 KB
/
tests.cpp
File metadata and controls
94 lines (77 loc) · 2.23 KB
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
89
90
91
92
93
94
#define BOOST_TEST_MODULE tests
#include <boost/test/unit_test.hpp>
#include "model.hpp"
using namespace IOSKJ;
BOOST_AUTO_TEST_SUITE(model)
/**
* @class IOSKJ::Model
* @test equilibrium_stable
*
* Test that when there is no substantial change in equilibrium
* conditions given further simulation.
*/
BOOST_AUTO_TEST_CASE(equilibrium_stable){
Model model;
model.track_open("equilibrium_stable.txt");
model.inititialise();
auto biomass_equil = model.biomass;
model.recruits_variation_on = false;
model.exploitation_on = false;
model.years(0,100);
const double tolerance = 0.01; //0.01%
BOOST_CHECK_CLOSE(biomass_equil(W),model.biomass(W),tolerance);
BOOST_CHECK_CLOSE(biomass_equil(M),model.biomass(M),tolerance);
BOOST_CHECK_CLOSE(biomass_equil(E),model.biomass(E),tolerance);
}
/**
* @class IOSKJ::Model
* @test equilibrium_uniform
*
* Test that when there is no movement and equal
* reruitment distribution that the equilibrium biomass
* is equal in all areas
*/
BOOST_AUTO_TEST_CASE(equilibrium_uniform){
Model model;
model.recruits_uniform();
model.movement_none();
model.initialise();
const double tolerance = 0.01; //0.01%
BOOST_CHECK_CLOSE(model.biomass(W),model.biomass(M),tolerance);
BOOST_CHECK_CLOSE(model.biomass(M),model.biomass(E),tolerance);
BOOST_CHECK_CLOSE(model.biomass(W),model.biomass(E),tolerance);
}
/**
* @class IOSKJ::Model
* @test recruiment_variation
*
* Test that recruitment variation has the right mean and
* standard deviation.
*/
BOOST_AUTO_TEST_CASE(recruiment_variation){
Model model;
model.track_open("recruiment_variation.txt");
model.initialise();
model.exploitation_on = false;
Stats stats;
for(int year=0;year<1000;year++){
model.year(year);
stats(model.recruits_deviation);
}
BOOST_CHECK_CLOSE(mean(stats),1,5);
BOOST_CHECK_CLOSE(std::pow(variance(stats),0.5),model.recruits_sd,10);
}
/**
* @class IOSKJ::Model
* @test exploitation_specified
*
*/
BOOST_AUTO_TEST_CASE(exploitation_specified){
Model model;
model.track_open("exploitation_specified.txt");
model.initialise();
model.recruits_variation_on = false;
model.exploitation_rate_set(0);
model.years(0,20);
}
BOOST_AUTO_TEST_SUITE_END()