Skip to content

Commit 98b2218

Browse files
author
corot
committed
Remake DefaultWronglyOverriden test as AllowEmptyValues
1 parent 317ae5d commit 98b2218

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

tests/gtest_ports.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -679,29 +679,36 @@ TEST(PortTest, Default_Issues_767)
679679
"default nullptr"));
680680
}
681681

682-
TEST(PortTest, DefaultWronglyOverriden)
682+
TEST(PortTest, AllowEmptyValues)
683683
{
684684
BT::BehaviorTreeFactory factory;
685+
factory.registerNodeType<NodeWithPorts>("NodeWithPorts");
685686
factory.registerNodeType<NodeWithDefaultNullptr>("NodeWithDefaultNullptr");
686687

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"(
688696
<root BTCPP_format="4" >
689697
<BehaviorTree>
690698
<NodeWithDefaultNullptr input=""/>
691699
</BehaviorTree>
692700
</root>)";
693701

694-
std::string xml_txt_correct = R"(
702+
std::string xml_txt_empty_default = R"(
695703
<root BTCPP_format="4" >
696704
<BehaviorTree>
697705
<NodeWithDefaultNullptr/>
698706
</BehaviorTree>
699707
</root>)";
700708

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));
707714
}

0 commit comments

Comments
 (0)