@@ -63,6 +63,9 @@ class CLASSNAME (TestGraphFixture, RMW_IMPLEMENTATION) : public ::testing::Test
6363 rcl_wait_set_t * wait_set_ptr;
6464 const char * test_graph_node_name = " test_graph_node" ;
6565
66+ rmw_participants_t * participants;
67+ const char * topic_name = " valid_topic_name" ;
68+
6669 void SetUp ()
6770 {
6871 rcl_ret_t ret;
@@ -101,6 +104,12 @@ class CLASSNAME (TestGraphFixture, RMW_IMPLEMENTATION) : public ::testing::Test
101104 ret = rcl_wait_set_init (
102105 this ->wait_set_ptr , 0 , 1 , 0 , 0 , 0 , 0 , this ->context_ptr , rcl_get_default_allocator ());
103106 ASSERT_EQ (RCL_RET_OK, ret) << rcl_get_error_string ().str ;
107+
108+ rmw_participants_t valid_participants = {
109+ 0 , /* count*/
110+ nullptr /* participants*/
111+ };
112+ this ->participants = &valid_participants;
104113 }
105114
106115 void TearDown ()
@@ -1321,3 +1330,126 @@ TEST_F(CLASSNAME(TestGraphFixture, RMW_IMPLEMENTATION), test_rcl_service_server_
13211330 wait_for_service_state_to_change (false , is_available);
13221331 ASSERT_FALSE (is_available);
13231332}
1333+
1334+
1335+ /*
1336+ * This does not test content of the response.
1337+ * It only tests if the return code is the one expected.
1338+ */
1339+ TEST_F (CLASSNAME(TestGraphFixture, RMW_IMPLEMENTATION),
1340+ test_rcl_get_qos_for_publishers_null_node)
1341+ {
1342+ auto ret = rcl_get_qos_for_publishers (nullptr , this ->topic_name , this ->participants );
1343+ EXPECT_EQ (RCL_RET_NODE_INVALID, ret);
1344+ }
1345+
1346+ /*
1347+ * This does not test content of the response.
1348+ * It only tests if the return code is the one expected.
1349+ */
1350+ TEST_F (CLASSNAME(TestGraphFixture, RMW_IMPLEMENTATION),
1351+ test_rcl_get_qos_for_subscribers_null_node)
1352+ {
1353+ auto ret = rcl_get_qos_for_subscribers (nullptr , this ->topic_name , this ->participants );
1354+ EXPECT_EQ (RCL_RET_NODE_INVALID, ret);
1355+ }
1356+
1357+ /*
1358+ * This does not test content of the response.
1359+ * It only tests if the return code is the one expected.
1360+ */
1361+ TEST_F (CLASSNAME(TestGraphFixture, RMW_IMPLEMENTATION),
1362+ test_rcl_get_qos_for_publishers_invalid_node)
1363+ {
1364+ // this->old_node_ptr is a pointer to an invalid node.
1365+ auto ret =
1366+ rcl_get_qos_for_publishers (this ->old_node_ptr , this ->topic_name , this ->participants );
1367+ EXPECT_EQ (RCL_RET_NODE_INVALID, ret);
1368+ }
1369+
1370+ /*
1371+ * This does not test content of the response.
1372+ * It only tests if the return code is the one expected.
1373+ */
1374+ TEST_F (CLASSNAME(TestGraphFixture, RMW_IMPLEMENTATION),
1375+ test_rcl_get_qos_for_subscribers_invalid_node)
1376+ {
1377+ // this->old_node_ptr is a pointer to an invalid node.
1378+ auto ret = rcl_get_qos_for_subscribers (this ->old_node_ptr , this ->topic_name ,
1379+ this ->participants );
1380+ EXPECT_EQ (RCL_RET_NODE_INVALID, ret);
1381+ }
1382+
1383+ /*
1384+ * This does not test content of the response.
1385+ * It only tests if the return code is the one expected.
1386+ */
1387+ TEST_F (CLASSNAME(TestGraphFixture, RMW_IMPLEMENTATION),
1388+ test_rcl_get_qos_for_publishers_null_topic)
1389+ {
1390+ auto ret = rcl_get_qos_for_publishers (this ->node_ptr , nullptr , this ->participants );
1391+ EXPECT_EQ (RCL_RET_INVALID_ARGUMENT, ret);
1392+ }
1393+
1394+ /*
1395+ * This does not test content of the response.
1396+ * It only tests if the return code is the one expected.
1397+ */
1398+ TEST_F (CLASSNAME(TestGraphFixture, RMW_IMPLEMENTATION),
1399+ test_rcl_get_qos_for_subscribers_null_topic)
1400+ {
1401+ auto ret = rcl_get_qos_for_subscribers (this ->node_ptr , nullptr , this ->participants );
1402+ EXPECT_EQ (RCL_RET_INVALID_ARGUMENT, ret);
1403+ }
1404+
1405+ /*
1406+ * This does not test content of the response.
1407+ * It only tests if the return code is the one expected.
1408+ */
1409+ TEST_F (CLASSNAME(TestGraphFixture, RMW_IMPLEMENTATION),
1410+ test_rcl_get_qos_for_publishers_null_participants)
1411+ {
1412+ auto ret = rcl_get_qos_for_publishers (this ->node_ptr , this ->topic_name , nullptr );
1413+ EXPECT_EQ (RCL_RET_INVALID_ARGUMENT, ret);
1414+ }
1415+
1416+ /*
1417+ * This does not test content of the response.
1418+ * It only tests if the return code is the one expected.
1419+ */
1420+ TEST_F (CLASSNAME(TestGraphFixture, RMW_IMPLEMENTATION),
1421+ test_rcl_get_qos_for_subscribers_null_participants)
1422+ {
1423+ auto ret = rcl_get_qos_for_subscribers (this ->node_ptr , this ->topic_name , nullptr );
1424+ EXPECT_EQ (RCL_RET_INVALID_ARGUMENT, ret);
1425+ }
1426+
1427+ /*
1428+ * This does not test content of the response.
1429+ * It only tests if the return code is the one expected.
1430+ */
1431+ TEST_F (CLASSNAME(TestGraphFixture, RMW_IMPLEMENTATION),
1432+ test_rcl_get_qos_for_publishers_invalid_participants)
1433+ {
1434+ // this participant is invalid as the pointer "participants" inside is expected to be null.
1435+ this ->participants ->participants =
1436+ reinterpret_cast <rmw_participant_qos_profile_t *>(malloc (
1437+ sizeof (rmw_participant_qos_profile_t *)));
1438+ auto ret = rcl_get_qos_for_publishers (this ->node_ptr , this ->topic_name , this ->participants );
1439+ EXPECT_EQ (RCL_RET_INVALID_ARGUMENT, ret);
1440+ }
1441+
1442+ /*
1443+ * This does not test content of the response.
1444+ * It only tests if the return code is the one expected.
1445+ */
1446+ TEST_F (CLASSNAME(TestGraphFixture, RMW_IMPLEMENTATION),
1447+ test_rcl_get_qos_for_subscribers_invalid_participants)
1448+ {
1449+ // this participant is invalid as the pointer "participants" inside is expected to be null.
1450+ this ->participants ->participants =
1451+ reinterpret_cast <rmw_participant_qos_profile_t *>(malloc (
1452+ sizeof (rmw_participant_qos_profile_t *)));
1453+ auto ret = rcl_get_qos_for_subscribers (this ->node_ptr , this ->topic_name , this ->participants );
1454+ EXPECT_EQ (RCL_RET_INVALID_ARGUMENT, ret);
1455+ }
0 commit comments