Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
facontidavide committed Jun 18, 2024
1 parent ced041b commit bcceae7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/xml_parsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,13 @@ void VerifyXML(const std::string& xml_text,
}
//-------------------------------------------------

int behavior_tree_count = 0;
for(auto child = xml_root->FirstChildElement(); child != nullptr;
child = child->NextSiblingElement())
{
behavior_tree_count++;
}

// function to be called recursively
std::function<void(const XMLElement*)> recursiveStep;

Expand Down Expand Up @@ -482,7 +489,7 @@ void VerifyXML(const std::string& xml_text,
}
else if(name == "BehaviorTree")
{
if(ID.empty())
if(ID.empty() && behavior_tree_count > 1)
{
ThrowError(line_number, "The tag <BehaviorTree> must have the "
"attribute [ID]");
Expand Down
4 changes: 2 additions & 2 deletions tests/gtest_ports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ TEST(PortTest, Descriptions)
<BehaviorTree ID="MainTree" _description="this is my tree" >
<Sequence>
<NodeWithPorts name="first" in_port_B="66" _description="this is my action" />
<SubTree ID="SubTree" name="second" _description="this is a subtree"/>
<SubTree ID="mySubTree" name="second" _description="this is a subtree"/>
</Sequence>
</BehaviorTree>
<BehaviorTree ID="SubTree" _description="this is a subtree" >
<BehaviorTree ID="mySubTree" _description="this is a subtree" >
<NodeWithPorts name="third" in_port_B="99" />
</BehaviorTree>
Expand Down

0 comments on commit bcceae7

Please sign in to comment.