@@ -679,29 +679,36 @@ TEST(PortTest, Default_Issues_767)
679
679
" default nullptr" ));
680
680
}
681
681
682
- TEST (PortTest, DefaultWronglyOverriden )
682
+ TEST (PortTest, AllowEmptyValues )
683
683
{
684
684
BT::BehaviorTreeFactory factory;
685
+ factory.registerNodeType <NodeWithPorts>(" NodeWithPorts" );
685
686
factory.registerNodeType <NodeWithDefaultNullptr>(" NodeWithDefaultNullptr" );
686
687
687
- std::string xml_txt_wrong = R"(
688
+ std::string xml_txt_empty_number = R"(
689
+ <root BTCPP_format="4" >
690
+ <BehaviorTree>
691
+ <NodeWithPorts in_port_A=""/>
692
+ </BehaviorTree>
693
+ </root>)" ;
694
+
695
+ std::string xml_txt_empty_pointer = R"(
688
696
<root BTCPP_format="4" >
689
697
<BehaviorTree>
690
698
<NodeWithDefaultNullptr input=""/>
691
699
</BehaviorTree>
692
700
</root>)" ;
693
701
694
- std::string xml_txt_correct = R"(
702
+ std::string xml_txt_empty_default = R"(
695
703
<root BTCPP_format="4" >
696
704
<BehaviorTree>
697
705
<NodeWithDefaultNullptr/>
698
706
</BehaviorTree>
699
707
</root>)" ;
700
708
701
- // this should throw, because we are NOT using the default,
702
- // but overriding it with an empty string instead.
703
- // See issue 768 for reference
704
- ASSERT_ANY_THROW (auto tree = factory.createTreeFromText (xml_txt_wrong));
705
- // This is correct
706
- ASSERT_NO_THROW (auto tree = factory.createTreeFromText (xml_txt_correct));
709
+ // All are correct, as we allow empty strings that will get retrieved as std::nullopt
710
+ // Note that this is the opposite request on issue 768
711
+ ASSERT_NO_THROW (auto tree = factory.createTreeFromText (xml_txt_empty_number));
712
+ ASSERT_NO_THROW (auto tree = factory.createTreeFromText (xml_txt_empty_pointer));
713
+ ASSERT_NO_THROW (auto tree = factory.createTreeFromText (xml_txt_empty_default));
707
714
}
0 commit comments