@@ -308,26 +308,40 @@ def test_get_liveliness_lost_status(datawriter):
308308 assert (0 == status .total_count_change )
309309
310310
311- def test_get_matched_subscription_data (datawriter ):
311+ def test_get_matched_subscription_data (datawriter , reader_topic , subscriber ):
312312 """
313313 This test checks:
314314 - DataWriter::get_matched_subscription_data
315315 """
316+ # Check with an invalid instance handle
316317 sub_data = fastdds .SubscriptionBuiltinTopicData ()
317318 ih = fastdds .InstanceHandle_t ()
318319 assert (fastdds .RETCODE_BAD_PARAMETER ==
319320 datawriter .get_matched_subscription_data (sub_data , ih ))
320321
322+ # Add a reader and check that the datawriter has matched subscriptions
323+ datareader = subscriber .create_datareader (reader_topic , fastdds .DATAREADER_QOS_DEFAULT )
324+ time .sleep (1 )
325+ assert (fastdds .RETCODE_OK ==
326+ datawriter .get_matched_subscription_data (sub_data , datareader .get_instance_handle ()))
327+ assert (sub_data .guid == datareader .guid ())
328+ assert (fastdds .RETCODE_OK ==
329+ subscriber .delete_datareader (datareader ))
321330
322- def test_get_matched_subscriptions (datawriter ):
331+ def test_get_matched_subscriptions (datawriter , reader_topic , subscriber ):
323332 """
324333 This test checks:
325334 - DataWriter::get_matched_subscriptions
326335 """
327336 ihs = fastdds .InstanceHandleVector ()
337+ # Add a reader and check that the datawriter has matched subscriptions
338+ datareader = subscriber .create_datareader (reader_topic , fastdds .DATAREADER_QOS_DEFAULT )
339+ time .sleep (1 )
340+ assert (fastdds .RETCODE_OK == datawriter .get_matched_subscriptions (ihs ))
341+ assert (1 == ihs .size ())
342+ assert (ihs [0 ] == datareader .get_instance_handle ())
328343 assert (fastdds .RETCODE_OK ==
329- datawriter .get_matched_subscriptions (ihs ))
330-
344+ subscriber .delete_datareader (datareader ))
331345
332346def test_get_offered_deadline_missed_status (datawriter ):
333347 """
0 commit comments