Skip to content

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
facontidavide committed Mar 19, 2024
1 parent ead514d commit 55a7b70
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ endif()
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -DWIN32_LEAN_AND_MEAN)
else()
add_definitions(-Wpedantic)
add_definitions(-Wpedantic -fno-omit-frame-pointer)
endif()


#---- project configuration ----
option(BTCPP_SHARED_LIBS "Build shared libraries" ON)
option(BTCPP_BUILD_TOOLS "Build commandline tools" ON)
Expand Down
1 change: 0 additions & 1 deletion include/behaviortree_cpp/blackboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ inline void Blackboard::set(const std::string& key, const T& value)
}
lock.lock();

storage_.insert({ key, entry });
entry->value = new_value;
}
else
Expand Down
20 changes: 10 additions & 10 deletions src/blackboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,31 +210,31 @@ std::shared_ptr<Blackboard::Entry> Blackboard::createEntryImpl(const std::string
return storage_it->second;
}

std::shared_ptr<Entry> entry;

// manual remapping first
auto remapping_it = internal_to_external_.find(key);
if(remapping_it != internal_to_external_.end())
{
const auto& remapped_key = remapping_it->second;
if(auto parent = parent_bb_.lock())
{
entry = parent->createEntryImpl(remapped_key, info);
return parent->createEntryImpl(remapped_key, info);
}
throw RuntimeError("Missing parent blackboard");
}
else if(autoremapping_ && !IsPrivateKey(key))
// autoremapping second (excluding private keys)
if(autoremapping_ && !IsPrivateKey(key))
{
if(auto parent = parent_bb_.lock())
{
return parent->createEntryImpl(key, info);
}
throw RuntimeError("Missing parent blackboard");
}
else // not remapped, not found. Create locally.
{
entry = std::make_shared<Entry>(info);
// even if empty, let's assign to it a default type
entry->value = Any(info.type());
}
// not remapped, not found. Create locally.

auto entry = std::make_shared<Entry>(info);
// even if empty, let's assign to it a default type
entry->value = Any(info.type());
storage_.insert({ key, entry });
return entry;
}
Expand Down
4 changes: 0 additions & 4 deletions tests/gtest_blackboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@
*/

#include <gtest/gtest.h>
#include "action_test_node.h"
#include "condition_test_node.h"
#include "behaviortree_cpp/behavior_tree.h"
#include "behaviortree_cpp/bt_factory.h"
#include "behaviortree_cpp/blackboard.h"
#include "behaviortree_cpp/xml_parsing.h"

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

Expand Down

0 comments on commit 55a7b70

Please sign in to comment.