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

Function TEST

tests/gtest_reactive.cpp:11–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9using std::chrono::milliseconds;
10
11TEST(Reactive, RunningChildren)
12{
13 static const char* reactive_xml_text = R"(
14<root BTCPP_format="4" >
15 <BehaviorTree ID="MainTree">
16 <ReactiveSequence>
17 <Sequence name="first">
18 <TestA/>
19 <TestB/>
20 <TestC/>
21 </Sequence>
22 <AsyncSequence name="second">
23 <TestD/>
24 <TestE/>
25 <TestF/>
26 </AsyncSequence>
27 </ReactiveSequence>
28 </BehaviorTree>
29</root>
30)";
31
32 BT::BehaviorTreeFactory factory;
33 std::array<int, 6> counters{};
34 RegisterTestTick(factory, "Test", counters);
35
36 auto tree = factory.createTreeFromText(reactive_xml_text);
37
38 NodeStatus status = NodeStatus::IDLE;
39
40 int count = 0;
41 while(!BT::isStatusCompleted(status) && count < 100)
42 {
43 count++;
44 status = tree.tickExactlyOnce();
45 }
46
47 ASSERT_NE(100, count);
48
49 ASSERT_EQ(status, NodeStatus::SUCCESS);
50
51 ASSERT_EQ(counters[0], 3);
52 ASSERT_EQ(counters[1], 3);
53 ASSERT_EQ(counters[2], 3);
54
55 ASSERT_EQ(counters[3], 1);
56 ASSERT_EQ(counters[4], 1);
57 ASSERT_EQ(counters[5], 1);
58}
59
60TEST(Reactive, Issue587)
61{

Callers

nothing calls this directly

Calls 10

RegisterTestTickFunction · 0.85
isStatusCompletedFunction · 0.85
createTreeFromTextMethod · 0.80
tickExactlyOnceMethod · 0.80
tickWhileRunningMethod · 0.80
applyVisitorMethod · 0.80
setPreTickFunctionMethod · 0.80
tickOnceMethod · 0.80
nameMethod · 0.45

Tested by

no test coverage detected