MCPcopy Create free account
hub / github.com/BehaviorTree/BehaviorTree.CPP / TEST

Function TEST

tests/gtest_decorator.cpp:218–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216}
217
218TEST(Decorator, RunOnce)
219{
220 BT::BehaviorTreeFactory factory;
221 std::array<int, 2> counters{};
222 RegisterTestTick(factory, "Test", counters);
223
224 const std::string xml_text = R"(
225 <root BTCPP_format="4" >
226 <BehaviorTree>
227 <Sequence>
228 <RunOnce> <TestA/> </RunOnce>
229 <TestB/>
230 </Sequence>
231 </BehaviorTree>
232 </root>)";
233
234 auto tree = factory.createTreeFromText(xml_text);
235
236 for(int i = 0; i < 5; i++)
237 {
238 NodeStatus status = tree.tickWhileRunning();
239 ASSERT_EQ(status, NodeStatus::SUCCESS);
240 }
241 // counters[0] contains the number of times TestA was ticked
242 ASSERT_EQ(counters[0], 1);
243 // counters[1] contains the number of times TestB was ticked
244 ASSERT_EQ(counters[1], 5);
245}
246
247// Test for DelayNode with XML: delay_msec port should be honored
248TEST(Decorator, DelayWithXML)

Callers

nothing calls this directly

Calls 5

RegisterTestTickFunction · 0.85
createTreeFromTextMethod · 0.80
tickWhileRunningMethod · 0.80
tickOnceMethod · 0.80
registerSimpleActionMethod · 0.80

Tested by

no test coverage detected