File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -69,8 +69,10 @@ QoSInitialization::from_rmw(const rmw_qos_profile_t & rmw_qos)
6969 return KeepLast (rmw_qos.depth , false );
7070 case RMW_QOS_POLICY_HISTORY_KEEP_LAST:
7171 case RMW_QOS_POLICY_HISTORY_UNKNOWN:
72- default :
7372 return KeepLast (rmw_qos.depth );
73+ default :
74+ throw std::invalid_argument (
75+ " Invalid history policy enum value passed to QoSInitialization::from_rmw" );
7476 }
7577}
7678
Original file line number Diff line number Diff line change @@ -272,3 +272,14 @@ TEST(TestQoS, qos_check_compatible)
272272 }
273273 }
274274}
275+
276+ TEST (TestQoS, from_rmw_validity)
277+ {
278+ rmw_qos_profile_t invalid_qos;
279+ memset (&invalid_qos, 0 , sizeof (invalid_qos));
280+ reinterpret_cast <uint32_t &>(invalid_qos.history ) = 999 ;
281+
282+ EXPECT_THROW ({
283+ rclcpp::QoSInitialization::from_rmw (invalid_qos);
284+ }, std::invalid_argument);
285+ }
You can’t perform that action at this time.
0 commit comments