@@ -26,10 +26,8 @@ class NodeWithPorts : public SyncActionNode
2626
2727 static PortsList providedPorts ()
2828 {
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" )};
3331 }
3432};
3533
@@ -38,19 +36,49 @@ TEST(PortTest, DefaultPorts)
3836 std::string xml_txt = R"(
3937 <root BTCPP_format="4" >
4038 <BehaviorTree ID="MainTree">
41- <NodeWithPorts name = "first" in_port_B="66" />
39+ <NodeWithPorts in_port_B="66" />
4240 </BehaviorTree>
4341 </root>)" ;
4442
4543 BehaviorTreeFactory factory;
4644 factory.registerNodeType <NodeWithPorts>(" NodeWithPorts" );
47-
4845 auto tree = factory.createTreeFromText (xml_txt);
49-
5046 NodeStatus status = tree.tickWhileRunning ();
5147 ASSERT_EQ (status, NodeStatus::SUCCESS);
5248}
5349
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+
5482TEST (PortTest, Descriptions)
5583{
5684 std::string xml_txt = R"(
0 commit comments