Merge 98b2218062
into 8d47d397e7
This commit is contained in:
commit
ce65b96337
|
@ -703,7 +703,7 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
|
||||||
") but not in the providedPorts() of its "
|
") but not in the providedPorts() of its "
|
||||||
"registered node type."));
|
"registered node type."));
|
||||||
}
|
}
|
||||||
else
|
else if(!port_value.empty())
|
||||||
{
|
{
|
||||||
const auto& port_model = port_model_it->second;
|
const auto& port_model = port_model_it->second;
|
||||||
bool is_blacbkboard = port_value.size() >= 3 && port_value.front() == '{' &&
|
bool is_blacbkboard = port_value.size() >= 3 && port_value.front() == '{' &&
|
||||||
|
|
|
@ -704,29 +704,36 @@ TEST(PortTest, Default_Issues_767)
|
||||||
"default nullptr"));
|
"default nullptr"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PortTest, DefaultWronglyOverriden)
|
TEST(PortTest, AllowEmptyValues)
|
||||||
{
|
{
|
||||||
BT::BehaviorTreeFactory factory;
|
BT::BehaviorTreeFactory factory;
|
||||||
|
factory.registerNodeType<NodeWithPorts>("NodeWithPorts");
|
||||||
factory.registerNodeType<NodeWithDefaultNullptr>("NodeWithDefaultNullptr");
|
factory.registerNodeType<NodeWithDefaultNullptr>("NodeWithDefaultNullptr");
|
||||||
|
|
||||||
std::string xml_txt_wrong = R"(
|
std::string xml_txt_empty_number = R"(
|
||||||
|
<root BTCPP_format="4" >
|
||||||
|
<BehaviorTree>
|
||||||
|
<NodeWithPorts in_port_A=""/>
|
||||||
|
</BehaviorTree>
|
||||||
|
</root>)";
|
||||||
|
|
||||||
|
std::string xml_txt_empty_pointer = R"(
|
||||||
<root BTCPP_format="4" >
|
<root BTCPP_format="4" >
|
||||||
<BehaviorTree>
|
<BehaviorTree>
|
||||||
<NodeWithDefaultNullptr input=""/>
|
<NodeWithDefaultNullptr input=""/>
|
||||||
</BehaviorTree>
|
</BehaviorTree>
|
||||||
</root>)";
|
</root>)";
|
||||||
|
|
||||||
std::string xml_txt_correct = R"(
|
std::string xml_txt_empty_default = R"(
|
||||||
<root BTCPP_format="4" >
|
<root BTCPP_format="4" >
|
||||||
<BehaviorTree>
|
<BehaviorTree>
|
||||||
<NodeWithDefaultNullptr/>
|
<NodeWithDefaultNullptr/>
|
||||||
</BehaviorTree>
|
</BehaviorTree>
|
||||||
</root>)";
|
</root>)";
|
||||||
|
|
||||||
// this should throw, because we are NOT using the default,
|
// All are correct, as we allow empty strings that will get retrieved as std::nullopt
|
||||||
// but overriding it with an empty string instead.
|
// Note that this is the opposite request on issue 768
|
||||||
// See issue 768 for reference
|
ASSERT_NO_THROW(auto tree = factory.createTreeFromText(xml_txt_empty_number));
|
||||||
ASSERT_ANY_THROW(auto tree = factory.createTreeFromText(xml_txt_wrong));
|
ASSERT_NO_THROW(auto tree = factory.createTreeFromText(xml_txt_empty_pointer));
|
||||||
// This is correct
|
ASSERT_NO_THROW(auto tree = factory.createTreeFromText(xml_txt_empty_default));
|
||||||
ASSERT_NO_THROW(auto tree = factory.createTreeFromText(xml_txt_correct));
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue