Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b0ca622

Browse files
committed
fix unit tests
1 parent 3e7e6d3 commit b0ca622

10 files changed

+145
-148
lines changed

tests/gtest_decorator.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ TEST_F(DeadlineTest, DeadlineNotTriggeredTest)
118118

119119
TEST_F(RetryTest, RetryTestA)
120120
{
121-
action.setBoolean(false);
121+
action.setExpectedResult(NodeStatus::FAILURE);
122122

123123
root.executeTick();
124124
ASSERT_EQ(NodeStatus::FAILURE, root.status());
125125
ASSERT_EQ(3, action.tickCount() );
126126

127-
action.setBoolean(true);
127+
action.setExpectedResult(NodeStatus::SUCCESS);
128128
action.resetTicks();
129129

130130
root.executeTick();
@@ -134,15 +134,15 @@ TEST_F(RetryTest, RetryTestA)
134134

135135
TEST_F(RepeatTest, RepeatTestA)
136136
{
137-
action.setBoolean(false);
137+
action.setExpectedResult(NodeStatus::FAILURE);
138138

139139
root.executeTick();
140140
ASSERT_EQ(NodeStatus::FAILURE, root.status());
141141
ASSERT_EQ(1, action.tickCount() );
142142

143143
//-------------------
144144
action.resetTicks();
145-
action.setBoolean(true);
145+
action.setExpectedResult(NodeStatus::SUCCESS);
146146

147147
root.executeTick();
148148
ASSERT_EQ(NodeStatus::SUCCESS, root.status());
@@ -152,7 +152,7 @@ TEST_F(RepeatTest, RepeatTestA)
152152
// https://github.com/BehaviorTree/BehaviorTree.CPP/issues/57
153153
TEST_F(TimeoutAndRetry, Issue57)
154154
{
155-
action.setBoolean( false );
155+
action.setExpectedResult(NodeStatus::FAILURE);
156156

157157
auto t1 = std::chrono::high_resolution_clock::now();
158158

tests/gtest_fallback.cpp

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ struct ComplexFallbackWithMemoryTest : testing::Test
125125
TEST_F(SimpleFallbackTest, ConditionTrue)
126126
{
127127
// Ticking the root node
128-
condition.setBoolean(true);
128+
condition.setExpectedResult(NodeStatus::SUCCESS);
129129
BT::NodeStatus state = root.executeTick();
130130

131131
ASSERT_EQ(NodeStatus::SUCCESS, state);
@@ -137,14 +137,14 @@ TEST_F(SimpleFallbackTest, ConditionChangeWhileRunning)
137137
{
138138
BT::NodeStatus state = BT::NodeStatus::IDLE;
139139

140-
condition.setBoolean(false);
140+
condition.setExpectedResult(NodeStatus::FAILURE);
141141
state = root.executeTick();
142142

143143
ASSERT_EQ(NodeStatus::RUNNING, state);
144144
ASSERT_EQ(NodeStatus::FAILURE, condition.status());
145145
ASSERT_EQ(NodeStatus::RUNNING, action.status());
146146

147-
condition.setBoolean(true);
147+
condition.setExpectedResult(NodeStatus::SUCCESS);
148148
state = root.executeTick();
149149

150150
ASSERT_EQ(NodeStatus::RUNNING, state);
@@ -154,8 +154,8 @@ TEST_F(SimpleFallbackTest, ConditionChangeWhileRunning)
154154

155155
TEST_F(ReactiveFallbackTest, Condition1ToTrue)
156156
{
157-
condition_1.setBoolean(false);
158-
condition_2.setBoolean(false);
157+
condition_1.setExpectedResult(NodeStatus::FAILURE);
158+
condition_2.setExpectedResult(NodeStatus::FAILURE);
159159

160160
BT::NodeStatus state = root.executeTick();
161161

@@ -164,7 +164,7 @@ TEST_F(ReactiveFallbackTest, Condition1ToTrue)
164164
ASSERT_EQ(NodeStatus::FAILURE, condition_2.status());
165165
ASSERT_EQ(NodeStatus::RUNNING, action_1.status());
166166

167-
condition_1.setBoolean(true);
167+
condition_1.setExpectedResult(NodeStatus::SUCCESS);
168168

169169
state = root.executeTick();
170170

@@ -176,8 +176,8 @@ TEST_F(ReactiveFallbackTest, Condition1ToTrue)
176176

177177
TEST_F(ReactiveFallbackTest, Condition2ToTrue)
178178
{
179-
condition_1.setBoolean(false);
180-
condition_2.setBoolean(false);
179+
condition_1.setExpectedResult(NodeStatus::FAILURE);
180+
condition_2.setExpectedResult(NodeStatus::FAILURE);
181181

182182
BT::NodeStatus state = root.executeTick();
183183

@@ -186,7 +186,7 @@ TEST_F(ReactiveFallbackTest, Condition2ToTrue)
186186
ASSERT_EQ(NodeStatus::FAILURE, condition_2.status());
187187
ASSERT_EQ(NodeStatus::RUNNING, action_1.status());
188188

189-
condition_2.setBoolean(true);
189+
condition_2.setExpectedResult(NodeStatus::SUCCESS);
190190

191191
state = root.executeTick();
192192

@@ -198,7 +198,7 @@ TEST_F(ReactiveFallbackTest, Condition2ToTrue)
198198

199199
TEST_F(SimpleFallbackWithMemoryTest, ConditionFalse)
200200
{
201-
condition.setBoolean(false);
201+
condition.setExpectedResult(NodeStatus::FAILURE);
202202
BT::NodeStatus state = root.executeTick();
203203

204204
ASSERT_EQ(NodeStatus::RUNNING, state);
@@ -208,14 +208,14 @@ TEST_F(SimpleFallbackWithMemoryTest, ConditionFalse)
208208

209209
TEST_F(SimpleFallbackWithMemoryTest, ConditionTurnToTrue)
210210
{
211-
condition.setBoolean(false);
211+
condition.setExpectedResult(NodeStatus::FAILURE);
212212
BT::NodeStatus state = root.executeTick();
213213

214214
ASSERT_EQ(NodeStatus::RUNNING, state);
215215
ASSERT_EQ(NodeStatus::FAILURE, condition.status());
216216
ASSERT_EQ(NodeStatus::RUNNING, action.status());
217217

218-
condition.setBoolean(true);
218+
condition.setExpectedResult(NodeStatus::SUCCESS);
219219
state = root.executeTick();
220220

221221
ASSERT_EQ(NodeStatus::RUNNING, state);
@@ -238,7 +238,7 @@ TEST_F(ComplexFallbackWithMemoryTest, ConditionsTrue)
238238

239239
TEST_F(ComplexFallbackWithMemoryTest, Condition1False)
240240
{
241-
condition_1.setBoolean(false);
241+
condition_1.setExpectedResult(NodeStatus::FAILURE);
242242
BT::NodeStatus state = root.executeTick();
243243

244244
ASSERT_EQ(NodeStatus::SUCCESS, state);
@@ -252,8 +252,8 @@ TEST_F(ComplexFallbackWithMemoryTest, Condition1False)
252252

253253
TEST_F(ComplexFallbackWithMemoryTest, ConditionsFalse)
254254
{
255-
condition_1.setBoolean(false);
256-
condition_2.setBoolean(false);
255+
condition_1.setExpectedResult(NodeStatus::FAILURE);
256+
condition_2.setExpectedResult(NodeStatus::FAILURE);
257257
BT::NodeStatus state = root.executeTick();
258258

259259
ASSERT_EQ(NodeStatus::RUNNING, state);
@@ -267,11 +267,11 @@ TEST_F(ComplexFallbackWithMemoryTest, ConditionsFalse)
267267

268268
TEST_F(ComplexFallbackWithMemoryTest, Conditions1ToTrue)
269269
{
270-
condition_1.setBoolean(false);
271-
condition_2.setBoolean(false);
270+
condition_1.setExpectedResult(NodeStatus::FAILURE);
271+
condition_2.setExpectedResult(NodeStatus::FAILURE);
272272
BT::NodeStatus state = root.executeTick();
273273

274-
condition_1.setBoolean(true);
274+
condition_1.setExpectedResult(NodeStatus::SUCCESS);
275275
state = root.executeTick();
276276

277277
ASSERT_EQ(NodeStatus::RUNNING, state);
@@ -285,11 +285,11 @@ TEST_F(ComplexFallbackWithMemoryTest, Conditions1ToTrue)
285285

286286
TEST_F(ComplexFallbackWithMemoryTest, Conditions2ToTrue)
287287
{
288-
condition_1.setBoolean(false);
289-
condition_2.setBoolean(false);
288+
condition_1.setExpectedResult(NodeStatus::FAILURE);
289+
condition_2.setExpectedResult(NodeStatus::FAILURE);
290290
BT::NodeStatus state = root.executeTick();
291291

292-
condition_2.setBoolean(true);
292+
condition_2.setExpectedResult(NodeStatus::SUCCESS);
293293
state = root.executeTick();
294294

295295
ASSERT_EQ(NodeStatus::RUNNING, state);
@@ -303,10 +303,10 @@ TEST_F(ComplexFallbackWithMemoryTest, Conditions2ToTrue)
303303

304304
TEST_F(ComplexFallbackWithMemoryTest, Action1Failed)
305305
{
306-
action_1.setBoolean(false);
307-
action_2.setBoolean(true);
308-
condition_1.setBoolean(false);
309-
condition_2.setBoolean(false);
306+
action_1.setExpectedResult(NodeStatus::FAILURE);
307+
action_2.setExpectedResult(NodeStatus::SUCCESS);
308+
condition_1.setExpectedResult(NodeStatus::FAILURE);
309+
condition_2.setExpectedResult(NodeStatus::FAILURE);
310310

311311
BT::NodeStatus state = root.executeTick();
312312

tests/gtest_parallel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ TEST_F(ComplexParallelTest, ConditionsTrue)
192192

193193
TEST_F(ComplexParallelTest, ConditionRightFalse)
194194
{
195-
condition_R.setBoolean(false);
195+
condition_R.setExpectedResult(NodeStatus::FAILURE);
196196
BT::NodeStatus state = parallel_root.executeTick();
197197

198198
// All the actions are running
@@ -228,7 +228,7 @@ TEST_F(ComplexParallelTest, ConditionRightFalse)
228228

229229
TEST_F(ComplexParallelTest, ConditionRightFalseAction1Done)
230230
{
231-
condition_R.setBoolean(false);
231+
condition_R.setExpectedResult(NodeStatus::FAILURE);
232232

233233
parallel_left.setThresholdM(4);
234234

tests/gtest_sequence.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ TEST_F(SimpleSequenceTest, ConditionTrue)
230230

231231
TEST_F(SimpleSequenceTest, ConditionTurnToFalse)
232232
{
233-
condition.setBoolean(false);
233+
condition.setExpectedResult(NodeStatus::FAILURE);
234234
BT::NodeStatus state = root.executeTick();
235235

236236
state = root.executeTick();
@@ -322,7 +322,7 @@ TEST_F(ComplexSequenceTest, ComplexSequenceConditions1ToFalse)
322322
{
323323
BT::NodeStatus state = root.executeTick();
324324

325-
condition_1.setBoolean(false);
325+
condition_1.setExpectedResult(NodeStatus::FAILURE);
326326

327327
state = root.executeTick();
328328

@@ -337,7 +337,7 @@ TEST_F(ComplexSequenceTest, ComplexSequenceConditions2ToFalse)
337337
{
338338
BT::NodeStatus state = root.executeTick();
339339

340-
condition_2.setBoolean(false);
340+
condition_2.setExpectedResult(NodeStatus::FAILURE);
341341

342342
state = root.executeTick();
343343

@@ -366,7 +366,7 @@ TEST_F(SimpleSequenceWithMemoryTest, ConditionTurnToFalse)
366366
ASSERT_EQ(NodeStatus::SUCCESS, condition.status());
367367
ASSERT_EQ(NodeStatus::RUNNING, action.status());
368368

369-
condition.setBoolean(false);
369+
condition.setExpectedResult(NodeStatus::FAILURE);
370370
state = root.executeTick();
371371

372372
ASSERT_EQ(NodeStatus::RUNNING, state);
@@ -391,7 +391,7 @@ TEST_F(ComplexSequenceWithMemoryTest, Conditions1ToFase)
391391
{
392392
BT::NodeStatus state = root.executeTick();
393393

394-
condition_1.setBoolean(false);
394+
condition_1.setExpectedResult(NodeStatus::FAILURE);
395395
state = root.executeTick();
396396
// change in condition_1 does not affect the state of the tree,
397397
// since the seq_conditions was executed already
@@ -408,7 +408,7 @@ TEST_F(ComplexSequenceWithMemoryTest, Conditions2ToFalse)
408408
{
409409
BT::NodeStatus state = root.executeTick();
410410

411-
condition_2.setBoolean(false);
411+
condition_2.setExpectedResult(NodeStatus::FAILURE);
412412
state = root.executeTick();
413413
// change in condition_2 does not affect the state of the tree,
414414
// since the seq_conditions was executed already
@@ -425,7 +425,7 @@ TEST_F(ComplexSequenceWithMemoryTest, Action1DoneSeq)
425425
{
426426
root.executeTick();
427427

428-
condition_2.setBoolean(false);
428+
condition_2.setExpectedResult(NodeStatus::FAILURE);
429429
root.executeTick();
430430

431431
// change in condition_2 does not affect the state of the tree,

0 commit comments

Comments
 (0)