Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 12f75ea

Browse files
committed
add unot test BehaviorTree#725
1 parent 305637f commit 12f75ea

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

tests/gtest_blackboard.cpp

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 2018-2019 Davide Faconti, Eurecat - All Rights Reserved
1+
/* Copyright (C) 2018-2023 Davide Faconti, Eurecat - All Rights Reserved
22
*
33
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
44
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
@@ -18,6 +18,8 @@
1818
#include "behaviortree_cpp/blackboard.h"
1919
#include "behaviortree_cpp/xml_parsing.h"
2020

21+
#include "../sample_nodes/dummy_nodes.h"
22+
2123
using namespace BT;
2224

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

464+
TEST(BlackboardTest, SetBlackboard_Issue725)
465+
{
466+
BT::BehaviorTreeFactory factory;
467+
468+
const std::string xml_text = R"(
469+
<root BTCPP_format="4" >
470+
<BehaviorTree ID="MainTree">
471+
<Sequence>
472+
<SetBlackboard value="hello world" output_key="value" />
473+
<SetBlackboard value="{value}" output_key="other_value" />
474+
<SaySomething message="{other_value}" />
475+
</Sequence>
476+
</BehaviorTree>
477+
</root> )";
478+
479+
factory.registerNodeType<DummyNodes::SaySomething>("SaySomething");
480+
factory.registerBehaviorTreeFromText(xml_text);
481+
auto tree = factory.createTree("MainTree");
482+
const auto status = tree.tickWhileRunning();
483+
484+
ASSERT_EQ(status, BT::NodeStatus::SUCCESS);
485+
ASSERT_EQ("hello world", tree.rootBlackboard()->get<std::string>("value"));
486+
ASSERT_EQ("hello world", tree.rootBlackboard()->get<std::string>("other_value"));
487+
}
488+
489+
462490
TEST(BlackboardTest, NullOutputRemapping)
463491
{
464492
auto bb = Blackboard::create();

0 commit comments

Comments
 (0)