Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions rclcpp/test/rclcpp/test_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1752,6 +1752,27 @@ TEST_F(TestNode, set_parameter_undeclared_parameters_not_allowed) {
EXPECT_FALSE(node->set_parameter(rclcpp::Parameter(name, nan)).successful);
EXPECT_EQ(node->get_parameter(name).get_value<double>(), 50.0);
}
{
// setting a parameter to non-finite values with floating point range descriptor
auto name = "parameter"_unq;
rcl_interfaces::msg::ParameterDescriptor descriptor;
descriptor.floating_point_range.resize(1);
auto & floating_point_range = descriptor.floating_point_range.at(0);
constexpr double inf = std::numeric_limits<double>::infinity();
constexpr double nan = std::numeric_limits<double>::quiet_NaN();
floating_point_range.from_value = 0.0;
floating_point_range.to_value = inf;
floating_point_range.step = 0.0;
node->declare_parameter(name, 50.0, descriptor);
EXPECT_EQ(node->get_parameter(name).get_value<double>(), 50.0);

EXPECT_TRUE(node->set_parameter(rclcpp::Parameter(name, inf)).successful);
EXPECT_EQ(node->get_parameter(name).get_value<double>(), inf);
EXPECT_FALSE(node->set_parameter(rclcpp::Parameter(name, -inf)).successful);
EXPECT_EQ(node->get_parameter(name).get_value<double>(), inf);
EXPECT_FALSE(node->set_parameter(rclcpp::Parameter(name, nan)).successful);
EXPECT_EQ(node->get_parameter(name).get_value<double>(), inf);
}
{
// setting an array parameter with floating point range descriptor
auto name = "parameter"_unq;
Expand Down