| 20 | // ============ LoopNode with static queue (string parsed) ============ |
| 21 | |
| 22 | TEST(LoopNode, StaticIntQueue) |
| 23 | { |
| 24 | BehaviorTreeFactory factory; |
| 25 | |
| 26 | std::vector<int> received_values; |
| 27 | PortsList ports = { InputPort<int>("value") }; |
| 28 | factory.registerSimpleAction( |
| 29 | "RecordIntValue", |
| 30 | [&received_values](TreeNode& node) { |
| 31 | auto val = node.getInput<int>("value"); |
| 32 | if(val) |
| 33 | { |
| 34 | received_values.push_back(val.value()); |
| 35 | } |
| 36 | return NodeStatus::SUCCESS; |
| 37 | }, |
| 38 | ports); |
| 39 | |
| 40 | const std::string xml_text = R"( |
| 41 | <root BTCPP_format="4"> |
| 42 | <BehaviorTree> |
| 43 | <LoopInt queue="1;2;3;4;5" value="{val}"> |
| 44 | <RecordIntValue value="{val}"/> |
| 45 | </LoopInt> |
| 46 | </BehaviorTree> |
| 47 | </root>)"; |
| 48 | |
| 49 | auto tree = factory.createTreeFromText(xml_text); |
| 50 | auto status = tree.tickWhileRunning(); |
| 51 | |
| 52 | ASSERT_EQ(status, NodeStatus::SUCCESS); |
| 53 | ASSERT_EQ(received_values.size(), 5u); |
| 54 | EXPECT_EQ(received_values[0], 1); |
| 55 | EXPECT_EQ(received_values[1], 2); |
| 56 | EXPECT_EQ(received_values[2], 3); |
| 57 | EXPECT_EQ(received_values[3], 4); |
| 58 | EXPECT_EQ(received_values[4], 5); |
| 59 | } |
| 60 | |
| 61 | TEST(LoopNode, StaticDoubleQueue) |
| 62 | { |
nothing calls this directly
no test coverage detected