initialize_logging_ should be copied. (#1272)

Signed-off-by: Tomoya.Fujita <Tomoya.Fujita@sony.com>
This commit is contained in:
tomoya 2020-08-12 00:22:33 +09:00 committed by brawner
parent efef96e657
commit 954cc3d27f
2 changed files with 19 additions and 0 deletions

View file

@ -44,6 +44,7 @@ InitOptions::InitOptions(const InitOptions & other)
: InitOptions(*other.get_rcl_init_options())
{
shutdown_on_sigint = other.shutdown_on_sigint;
initialize_logging_ = other.initialize_logging_;
}
bool
@ -69,6 +70,7 @@ InitOptions::operator=(const InitOptions & other)
rclcpp::exceptions::throw_from_rcl_error(ret, "failed to copy rcl init options");
}
this->shutdown_on_sigint = other.shutdown_on_sigint;
this->initialize_logging_ = other.initialize_logging_;
}
return *this;
}

View file

@ -44,3 +44,20 @@ TEST(TestInitOptions, test_construction) {
ASSERT_TRUE(rcl_options_copy->impl != nullptr);
}
}
TEST(TestInitOptions, test_initialize_logging) {
{
auto options = rclcpp::InitOptions();
EXPECT_TRUE(options.auto_initialize_logging());
}
{
auto options = rclcpp::InitOptions().auto_initialize_logging(true);
EXPECT_TRUE(options.auto_initialize_logging());
}
{
auto options = rclcpp::InitOptions().auto_initialize_logging(false);
EXPECT_FALSE(options.auto_initialize_logging());
}
}