|
1 |
| -/* Copyright (C) 2018-2019 Davide Faconti, Eurecat - All Rights Reserved |
| 1 | +/* Copyright (C) 2018-2023 Davide Faconti, Eurecat - All Rights Reserved |
2 | 2 | *
|
3 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
4 | 4 | * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
18 | 18 | #include "behaviortree_cpp/blackboard.h"
|
19 | 19 | #include "behaviortree_cpp/xml_parsing.h"
|
20 | 20 |
|
| 21 | +#include "../sample_nodes/dummy_nodes.h" |
| 22 | + |
21 | 23 | using namespace BT;
|
22 | 24 |
|
23 | 25 | class BB_TestNode : public SyncActionNode
|
@@ -459,6 +461,32 @@ TEST(BlackboardTest, IssueSetBlackboard)
|
459 | 461 | ASSERT_EQ(42, tree.rootBlackboard()->get<int>("value"));
|
460 | 462 | }
|
461 | 463 |
|
| 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 | + |
462 | 490 | TEST(BlackboardTest, NullOutputRemapping)
|
463 | 491 | {
|
464 | 492 | auto bb = Blackboard::create();
|
|
0 commit comments