| 9 | using std::chrono::milliseconds; |
| 10 | |
| 11 | TEST(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 | |
| 60 | TEST(Reactive, Issue587) |
| 61 | { |
nothing calls this directly
no test coverage detected