Skip to content

Commit

Permalink
Initial tests
Browse files Browse the repository at this point in the history
Signed-off-by: Alberto Tudela <ajtudela@gmail.com>
  • Loading branch information
ajtudela committed Sep 23, 2024
1 parent 8e21e53 commit 6bba49c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dsr_util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ if(BUILD_TESTING)
set(ament_cmake_copyright_FOUND TRUE)
ament_lint_auto_find_test_dependencies()

# add_subdirectory(test)
add_subdirectory(test)
endif()

# Export old-style CMake variables
Expand Down
6 changes: 3 additions & 3 deletions dsr_util/include/dsr_util/dsr_api_ext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class DSRGraphExt : public DSR::DSRGraph
~DSRGraphExt() = default;

/**
* @brief Create a node with priority and source.
* @brief Create a node with priority and source attributes.
*
* @tparam node_type The type of the DSR node. Defined in ros_to_dsr_types.hpp.
* @param name Name of the DSR node.
Expand Down Expand Up @@ -85,7 +85,7 @@ class DSRGraphExt : public DSR::DSRGraph
}

/**
* @brief Create a node with the given name and the name of the parent.
* @brief Create a node with a position relative to the parent node.
*
* @tparam node_type The type of the DSR node. Defined in ros_to_dsr_types.hpp.
* @tparam edge_type The type of the DSR edge. Defined in ros_to_dsr_types.hpp.
Expand Down Expand Up @@ -124,7 +124,7 @@ class DSRGraphExt : public DSR::DSRGraph
}

/**
* @brief Create a edge with a source.
* @brief Create a edge with a source attribute.
*
* @tparam edge_type The type of the DSR edge. Defined in ros_to_dsr_types.hpp.
* @param from Id of the parent DSR node.
Expand Down
9 changes: 5 additions & 4 deletions dsr_util/test/test_dsr_api_ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class DSRApiExtTest : public ::testing::Test

void TearDown() override
{
std::this_thread::sleep_for(std::chrono::milliseconds(100));
G_.reset();
}

Expand Down Expand Up @@ -67,14 +68,14 @@ TEST_F(DSRApiExtTest, create_node_with_pose) {
G_->create_node_with_priority<robot_node_type>("parent_node", 0, "test_source");

if (auto id = G_->insert_node(parent_node); id.has_value()) {
auto node = G_->create_node_with_pose<robot_node_type, RT_edge_type>(
auto child_node = G_->create_node_with_pose<robot_node_type, RT_edge_type>(
"test_node", "parent_node", 0, "test_source");

EXPECT_EQ(node.name(), "test_node");
EXPECT_EQ(node.type(), "robot");
EXPECT_EQ(child_node.name(), "test_node");
EXPECT_EQ(child_node.type(), "robot");

// Check parent and level attributes, not the random position
auto attributes = node.attrs();
auto attributes = child_node.attrs();
auto search = attributes.find("parent");
EXPECT_TRUE(search != attributes.end());
EXPECT_EQ(std::get<uint64_t>(search->second.value()), id.value());
Expand Down

0 comments on commit 6bba49c

Please sign in to comment.