Skip to content

Commit 4d32cbb

Browse files
committed
Migrate to gtest
1 parent fc02994 commit 4d32cbb

File tree

7 files changed

+23
-22
lines changed

7 files changed

+23
-22
lines changed

.config/clang-format

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
2-
# C++ Formatting rules for Polymath Code Standard - https://gitlab.com/polymathrobotics/polymath_code_standard
3-
# Synced from origin - DO NOT EDIT IN CONSUMING REPOSITORY
2+
# C++ Formatting rules for Polymath Code Standard
43

54
# See https://releases.llvm.org/14.0.0/tools/clang/docs/ClangFormatStyleOptions.html for documentation of these options
65
BasedOnStyle: Google

behaviortree_cpp_pluginlib/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ if(BUILD_TESTING)
8181
@ONLY
8282
)
8383

84-
set(TEST_SOURCES
84+
ament_add_gtest(test_register
8585
test/test_register.cpp
8686
${PROJECT_BINARY_DIR}/test/autoregistrar.cpp
8787
)
88-
polymath_add_catch2_test(test_register "${TEST_SOURCES}" ${PROJECT_NAME})
88+
target_link_libraries(test_register ${PROJECT_NAME})
8989
endif()
9090

9191
ament_export_targets(${PROJECT_NAME}_TARGETS HAS_LIBRARY_TARGET)

behaviortree_cpp_pluginlib/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<depend>pluginlib</depend>
1616
<depend>rcutils</depend>
1717

18-
<test_depend>polymath_test</test_depend>
18+
<test_depend>ament_cmake_gtest</test_depend>
1919

2020
<export>
2121
<build_type>ament_cmake</build_type>

behaviortree_cpp_pluginlib/test/test_register.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <string>
1616

1717
#include "behaviortree_cpp_pluginlib/register_macro.hpp"
18-
#include "polymath_test/catch2.hpp"
18+
#include "gtest/gtest.h"
1919

2020
namespace btplugin::testing
2121
{
@@ -50,19 +50,19 @@ BT_PLUGIN_REGISTER(factory)
5050
factory.registerNodeType<btplugin::testing::CustomNode3>("CustomNode3");
5151
}
5252

53-
TEST_CASE("Plugin registration macros")
53+
TEST(Registration, MacrosBasicUse)
5454
{
5555
BT::BehaviorTreeFactory factory;
5656

5757
auto plugin_fns = BT::get_plugin_register_functions();
58-
REQUIRE(plugin_fns.size() == 2);
58+
ASSERT_EQ(plugin_fns.size(), 2);
5959
for (const auto & plugin_fn : plugin_fns) {
6060
plugin_fn(factory);
6161
}
6262

6363
auto builders = factory.builders();
64-
REQUIRE_NOTHROW(builders.at("CustomNode1"));
65-
REQUIRE_NOTHROW(builders.at("CustomNode2"));
66-
REQUIRE_NOTHROW(builders.at("CustomNode3"));
67-
REQUIRE_THROWS_AS(builders.at("NonexistentNode"), std::out_of_range);
64+
ASSERT_NO_THROW(builders.at("CustomNode1"));
65+
ASSERT_NO_THROW(builders.at("CustomNode2"));
66+
ASSERT_NO_THROW(builders.at("CustomNode3"));
67+
ASSERT_THROW(builders.at("NonexistentNode"), std::out_of_range);
6868
}

behaviortree_cpp_pluginlib_tests/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ if(BUILD_TESTING)
5050
RUNTIME DESTINATION bin
5151
)
5252

53-
polymath_add_catch2_test(test_factory test/test_factory.cpp test_plugin_a)
54-
target_link_libraries(test_factory behaviortree_cpp_pluginlib::behaviortree_cpp_pluginlib)
53+
ament_add_gtest(test_factory test/test_factory.cpp)
54+
target_link_libraries(test_factory
55+
behaviortree_cpp_pluginlib::behaviortree_cpp_pluginlib
56+
)
5557
endif()
5658

5759
ament_package()

behaviortree_cpp_pluginlib_tests/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
<buildtool_depend>ament_cmake</buildtool_depend>
1212
<buildtool_depend>ament_cmake_auto</buildtool_depend>
1313

14+
<test_depend>ament_cmake_gtest</test_depend>
1415
<test_depend>behaviortree_cpp_pluginlib</test_depend>
15-
<test_depend>polymath_test</test_depend>
1616

1717
<export>
1818
<build_type>ament_cmake</build_type>

behaviortree_cpp_pluginlib_tests/test/test_factory.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
#include <vector>
1818

1919
#include "behaviortree_cpp_pluginlib/factory.hpp"
20-
#include "polymath_test/catch2.hpp"
20+
#include "gtest/gtest.h"
2121

22-
TEST_CASE("Autofactory finds plugins registered via the various macros")
22+
TEST(Factory, AutofactoryEndToEnd)
2323
{
2424
BT::PluginAwareFactory factory;
2525
const auto & builders = factory.builders();
26-
REQUIRE_NOTHROW(builders.at("CustomNodeA1"));
27-
REQUIRE_NOTHROW(builders.at("CustomNodeA2"));
28-
REQUIRE_NOTHROW(builders.at("CustomNodeB1"));
29-
REQUIRE_NOTHROW(builders.at("CustomNodeB2"));
30-
REQUIRE_THROWS_AS(builders.at("NonexistentNode"), std::out_of_range);
26+
ASSERT_NO_THROW(builders.at("CustomNodeA1"));
27+
ASSERT_NO_THROW(builders.at("CustomNodeA2"));
28+
ASSERT_NO_THROW(builders.at("CustomNodeB1"));
29+
ASSERT_NO_THROW(builders.at("CustomNodeB2"));
30+
ASSERT_THROW(builders.at("NonexistentNode"), std::out_of_range);
3131
}

0 commit comments

Comments
 (0)