Skip to content

Commit

Permalink
add unit test #725
Browse files Browse the repository at this point in the history
  • Loading branch information
facontidavide committed Dec 19, 2023
1 parent ae5b949 commit f88a4a5
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/gtest_blackboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include "behaviortree_cpp_v3/blackboard.h"
#include "behaviortree_cpp_v3/xml_parsing.h"

#include "../sample_nodes/dummy_nodes.h"

using namespace BT;

class BB_TestNode : public SyncActionNode
Expand Down Expand Up @@ -295,3 +297,28 @@ TEST(BlackboardTest, CheckTypeSafety)
is = std::is_constructible<BT::StringView, std::string>::value;
ASSERT_TRUE(is);
}

TEST(BlackboardTest, SetBlackboard_Issue725)
{
BT::BehaviorTreeFactory factory;

const std::string xml_text = R"(
<root main_tree_to_execute = "MainTree" >
<BehaviorTree ID="MainTree">
<Sequence>
<SetBlackboard value="hello world" output_key="value" />
<SetBlackboard value="{value}" output_key="other_value" />
<SaySomething message="{other_value}" />
</Sequence>
</BehaviorTree>
</root> )";

factory.registerNodeType<DummyNodes::SaySomething>("SaySomething");
factory.registerBehaviorTreeFromText(xml_text);
auto tree = factory.createTree("MainTree");
const auto status = tree.tickRoot();

ASSERT_EQ(status, BT::NodeStatus::SUCCESS);
ASSERT_EQ("hello world", tree.rootBlackboard()->get<std::string>("value"));
ASSERT_EQ("hello world", tree.rootBlackboard()->get<std::string>("other_value"));
}

0 comments on commit f88a4a5

Please sign in to comment.