-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello_test.cc
More file actions
178 lines (147 loc) · 5.42 KB
/
Copy pathhello_test.cc
File metadata and controls
178 lines (147 loc) · 5.42 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#include <gtest/gtest.h>
#include "unittest_SimpleMath/unittest_SimpleMath.h"
#include "unittest_SimpleMath/isolatedBoxCmake.h"
#include "unittest_SimpleMath/isolatedBoxCmake.cpp"
#include "unittest_SimpleMath/isolatedBox_PID.cpp"
#include "unittest_SimpleMath/isolatedBox_actuator.cpp"
using namespace isoBoxApi;
TEST(testIsolated, boxInit)
{
isoBox l_IsoBox = isoBox();
/// <summary>
/// The initialization set points for max and min
/// Should remain in the phisycal range determined
/// by the PID regulator (these are 20 and 100 expressed in Celsius)
/// </summary>
/// First test. Both value are under the minimum - Negative Logic
EXPECT_TRUE(!(l_IsoBox.init(1,2)));
/// Second test. Both value are over the maximum - Negative Logic
EXPECT_TRUE(!(l_IsoBox.init(101, 102)));
/// Third test. Min val is under the min treshold - Negative Logic
EXPECT_TRUE(!(l_IsoBox.init(1, 32)));
/// Fourth test. Max val is over the max treshold - Negative Logic
EXPECT_TRUE(!(l_IsoBox.init(21, 320)));
/// Fifth test. Max val = Min Val = default val - Negative Logic
EXPECT_TRUE(!(l_IsoBox.init(ISO_TEMP_SP_DEFAULT, ISO_TEMP_SP_DEFAULT)));
/// Sixth test. Max val > Min Val both in the range - Positive Logic
EXPECT_TRUE(l_IsoBox.init(25, 50));
}
TEST(testIsolated, testPointSettings)
{
isoBox l_IsoBox = isoBox();
temp_t l_minSetPoint = 25.0;
temp_t l_maxSetPoint = 50.0;
l_IsoBox.init(l_minSetPoint, l_maxSetPoint);
/// <summary>
/// Verify the Min set point
/// </summary>
/// <param name=""></param>
/// <param name=""></param>
EXPECT_EQ(l_minSetPoint, l_IsoBox.getSetPoint(PID_MIN_SET_POINT));
/// <summary>
/// Verify the max set point
/// </summary>
/// <param name=""></param>
/// <param name=""></param>
EXPECT_EQ(l_maxSetPoint, l_IsoBox.getSetPoint(PID_MAX_SET_POINT));
/// <summary>
/// By Default the target point is the minimum one
/// </summary>
/// <param name=""></param>
/// <param name=""></param>
EXPECT_EQ(l_minSetPoint, l_IsoBox.getTargetPoint());
/// <summary>
/// Change the target point and verify the new setting is OK
/// </summary>
/// <param name=""></param>
/// <param name=""></param>
l_IsoBox.setTargetPoint(PID_MAX_SET_POINT);
EXPECT_EQ(l_maxSetPoint, l_IsoBox.getTargetPoint());
}
TEST(testIsolated, failCompensation_init)
{
isoBox l_IsoBox = isoBox();
temp_t l_minSetPoint = 21.0;
temp_t l_maxSetPoint = 320.0;
l_IsoBox.init(l_minSetPoint, l_maxSetPoint);
/// <summary>
/// The apply compensation should fail (ISO_DEF_UNDEF_TEMP)
/// because the init is KO
/// </summary>
/// <param name=""></param>
/// <param name=""></param>
temp_t l_tempToMonitor = 37.0;
EXPECT_EQ(ISO_DEF_UNDEF_TEMP, l_IsoBox.applyCompensation(l_tempToMonitor));
}
TEST(testIsolated, failCompensation_runTime)
{
isoBox l_IsoBox = isoBox();
temp_t l_minSetPoint = 25.0;
temp_t l_maxSetPoint = 50.0;
l_IsoBox.init(l_minSetPoint, l_maxSetPoint);
/// <summary>
/// The apply compensation should fail(ISO_DEF_UNDEF_TEMP)
/// because the temp is in the range so we do not need to compensate
/// </summary>
/// <param name=""></param>
/// <param name=""></param>
temp_t l_tempToMonitor = 37.0;
EXPECT_EQ(ISO_DEF_UNDEF_TEMP, l_IsoBox.applyCompensation(l_tempToMonitor));
}
TEST(testIsolated, runCompensation)
{
isoBox l_IsoBox = isoBox();
temp_t l_minSetPoint = 25.0;
temp_t l_maxSetPoint = 50.0;
l_IsoBox.init(l_minSetPoint, l_maxSetPoint);
/// <summary>
/// The compensation should start to reach the
/// MAX (50.0) temperature point
/// </summary>
/// <param name=""></param>
/// <param name=""></param>
temp_t l_tempToMonitor = 51.0;
EXPECT_EQ(l_maxSetPoint, l_IsoBox.applyCompensation(l_tempToMonitor));
/// <summary>
/// The compensation starts from the MAX
/// </summary>
/// <param name=""></param>
/// <param name=""></param>
l_tempToMonitor = 52.0;
EXPECT_EQ(l_maxSetPoint, l_IsoBox.applyCompensation(l_tempToMonitor));
/// <summary>
/// The compensation restarts from the MIN
/// </summary>
/// <param name=""></param>
/// <param name=""></param>
l_tempToMonitor = 23.0;
EXPECT_EQ(l_minSetPoint, l_IsoBox.applyCompensation(l_tempToMonitor));
/// <summary>
/// The compensation should not apply because we are in the range
/// </summary>
/// <param name=""></param>
/// <param name=""></param>
l_tempToMonitor = 25.0;
EXPECT_EQ(ISO_DEF_UNDEF_TEMP, l_IsoBox.applyCompensation(l_tempToMonitor));
/// <summary>
/// The compensation restarts from the MIN
/// </summary>
/// <param name=""></param>
/// <param name=""></param>
l_tempToMonitor = 24.999;
EXPECT_EQ(l_minSetPoint, l_IsoBox.applyCompensation(l_tempToMonitor));
/// <summary>
/// The compensation should not apply because we are in the range
/// </summary>
/// <param name=""></param>
/// <param name=""></param>
l_tempToMonitor = 50.0;
EXPECT_EQ(ISO_DEF_UNDEF_TEMP, l_IsoBox.applyCompensation(l_tempToMonitor));
/// <summary>
/// The compensation restarts from the MAX
/// </summary>
/// <param name=""></param>
/// <param name=""></param>
l_tempToMonitor = 50.0001;
EXPECT_EQ(l_maxSetPoint, l_IsoBox.applyCompensation(l_tempToMonitor));
}