Skip to content

Commit c0a7f9f

Browse files
fujitatomoyabrawner
authored andcommitted
Ability to configure domain_id via InitOptions. (#1165)
Signed-off-by: Tomoya.Fujita <[email protected]> Remove non-foxy api changes Signed-off-by: Stephen Brawner <[email protected]>
1 parent 93839e1 commit c0a7f9f

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

rclcpp/test/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,11 @@ if(TARGET test_node_options)
253253
ament_target_dependencies(test_node_options "rcl")
254254
target_link_libraries(test_node_options ${PROJECT_NAME})
255255
endif()
256+
ament_add_gtest(test_init_options rclcpp/test_init_options.cpp)
257+
if(TARGET test_init_options)
258+
ament_target_dependencies(test_init_options "rcl")
259+
target_link_libraries(test_init_options ${PROJECT_NAME})
260+
endif()
256261
ament_add_gtest(test_parameter_client rclcpp/test_parameter_client.cpp)
257262
if(TARGET test_parameter_client)
258263
ament_target_dependencies(test_parameter_client
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright 2020 Open Source Robotics Foundation, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include <gtest/gtest.h>
16+
17+
#include <string>
18+
#include <vector>
19+
20+
#include "rcl/allocator.h"
21+
#include "rcl/domain_id.h"
22+
23+
#include "rclcpp/init_options.hpp"
24+
25+
26+
TEST(TestInitOptions, test_construction) {
27+
rcl_allocator_t allocator = rcl_get_default_allocator();
28+
auto options = rclcpp::InitOptions(allocator);
29+
const rcl_init_options_t * rcl_options = options.get_rcl_init_options();
30+
ASSERT_TRUE(rcl_options != nullptr);
31+
ASSERT_TRUE(rcl_options->impl != nullptr);
32+
33+
{
34+
auto options_copy = rclcpp::InitOptions(options);
35+
const rcl_init_options_t * rcl_options_copy = options_copy.get_rcl_init_options();
36+
ASSERT_TRUE(rcl_options_copy != nullptr);
37+
ASSERT_TRUE(rcl_options_copy->impl != nullptr);
38+
}
39+
40+
{
41+
auto options_copy = options;
42+
const rcl_init_options_t * rcl_options_copy = options_copy.get_rcl_init_options();
43+
ASSERT_TRUE(rcl_options_copy != nullptr);
44+
ASSERT_TRUE(rcl_options_copy->impl != nullptr);
45+
}
46+
}

0 commit comments

Comments
 (0)