@@ -26,10 +26,8 @@ class NodeWithPorts : public SyncActionNode
26
26
27
27
static PortsList providedPorts ()
28
28
{
29
- return {BT::InputPort<int >(" in_port_A" , 42 , " magic_number" ), BT::InputPort<int >(" in_"
30
- " port"
31
- " _"
32
- " B" )};
29
+ return {BT::InputPort<int >(" in_port_A" , 42 , " magic_number" ),
30
+ BT::InputPort<int >(" in_port_B" )};
33
31
}
34
32
};
35
33
@@ -38,19 +36,49 @@ TEST(PortTest, DefaultPorts)
38
36
std::string xml_txt = R"(
39
37
<root BTCPP_format="4" >
40
38
<BehaviorTree ID="MainTree">
41
- <NodeWithPorts name = "first" in_port_B="66" />
39
+ <NodeWithPorts in_port_B="66" />
42
40
</BehaviorTree>
43
41
</root>)" ;
44
42
45
43
BehaviorTreeFactory factory;
46
44
factory.registerNodeType <NodeWithPorts>(" NodeWithPorts" );
47
-
48
45
auto tree = factory.createTreeFromText (xml_txt);
49
-
50
46
NodeStatus status = tree.tickWhileRunning ();
51
47
ASSERT_EQ (status, NodeStatus::SUCCESS);
52
48
}
53
49
50
+
51
+ TEST (PortTest, MissingPort)
52
+ {
53
+ std::string xml_txt = R"(
54
+ <root BTCPP_format="4" >
55
+ <BehaviorTree ID="MainTree">
56
+ <NodeWithPorts/>
57
+ </BehaviorTree>
58
+ </root>)" ;
59
+
60
+ BehaviorTreeFactory factory;
61
+ factory.registerNodeType <NodeWithPorts>(" NodeWithPorts" );
62
+ auto tree = factory.createTreeFromText (xml_txt);
63
+ NodeStatus status = tree.tickWhileRunning ();
64
+ ASSERT_EQ (status, NodeStatus::FAILURE);
65
+ }
66
+
67
+ TEST (PortTest, WrongPort)
68
+ {
69
+ std::string xml_txt = R"(
70
+ <root BTCPP_format="4" >
71
+ <BehaviorTree ID="MainTree">
72
+ <NodeWithPorts da_port="66" />
73
+ </BehaviorTree>
74
+ </root>)" ;
75
+
76
+ BehaviorTreeFactory factory;
77
+ factory.registerNodeType <NodeWithPorts>(" NodeWithPorts" );
78
+
79
+ EXPECT_ANY_THROW (auto tree = factory.createTreeFromText (xml_txt));
80
+ }
81
+
54
82
TEST (PortTest, Descriptions)
55
83
{
56
84
std::string xml_txt = R"(
0 commit comments