Skip to content

Commit

Permalink
add unot test #725
Browse files Browse the repository at this point in the history
  • Loading branch information
facontidavide committed Dec 19, 2023
1 parent 305637f commit 12f75ea
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion tests/gtest_blackboard.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2018-2019 Davide Faconti, Eurecat - All Rights Reserved
/* Copyright (C) 2018-2023 Davide Faconti, Eurecat - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
Expand All @@ -18,6 +18,8 @@
#include "behaviortree_cpp/blackboard.h"
#include "behaviortree_cpp/xml_parsing.h"

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

using namespace BT;

class BB_TestNode : public SyncActionNode
Expand Down Expand Up @@ -459,6 +461,32 @@ TEST(BlackboardTest, IssueSetBlackboard)
ASSERT_EQ(42, tree.rootBlackboard()->get<int>("value"));
}

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

const std::string xml_text = R"(
<root BTCPP_format="4" >
<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.tickWhileRunning();

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


TEST(BlackboardTest, NullOutputRemapping)
{
auto bb = Blackboard::create();
Expand Down

0 comments on commit 12f75ea

Please sign in to comment.