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 @@ -259,3 +259,14 @@ TEST(TestQoS, qos_check_compatible)
259259 EXPECT_FALSE (ret.reason .empty ());
260260 }
261261}
262+
263+ TEST (TestQoS, from_rmw_validity)
264+ {
265+ rmw_qos_profile_t invalid_qos;
266+ memset (&invalid_qos, 0 , sizeof (invalid_qos));
267+ reinterpret_cast <uint32_t &>(invalid_qos.history ) = 999 ;
268+
269+ EXPECT_THROW ({
270+ rclcpp::QoSInitialization::from_rmw (invalid_qos);
271+ }, std::invalid_argument);
272+ }
You can’t perform that action at this time.
0 commit comments