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

Function TEST

tests/gtest_loop.cpp:22–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20// ============ LoopNode with static queue (string parsed) ============
21
22TEST(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
61TEST(LoopNode, StaticDoubleQueue)
62{

Callers

nothing calls this directly

Calls 9

registerSimpleActionMethod · 0.80
push_backMethod · 0.80
createTreeFromTextMethod · 0.80
tickWhileRunningMethod · 0.80
setMethod · 0.80
haltTreeMethod · 0.80
valueMethod · 0.45
sizeMethod · 0.45
rootBlackboardMethod · 0.45

Tested by

no test coverage detected