@@ -616,6 +616,19 @@ def test_topic_echo_field_nested(self):
616616 ), timeout = 10 )
617617 assert topic_command .wait_for_shutdown (timeout = 10 )
618618
619+ @launch_testing .markers .retry_on_failure (times = 5 , delay = 1 )
620+ def test_topic_echo_field_array (self ):
621+ with self .launch_topic_command (
622+ arguments = ['echo' , '/arrays' , '--field' , 'float32_values_default.[2]' ],
623+ ) as topic_command :
624+ assert topic_command .wait_for_output (functools .partial (
625+ launch_testing .tools .expect_output , expected_lines = [
626+ '-1.125' ,
627+ '---' ,
628+ ], strict = True
629+ ), timeout = 10 )
630+ assert topic_command .wait_for_shutdown (timeout = 10 )
631+
619632 @launch_testing .markers .retry_on_failure (times = 5 , delay = 1 )
620633 def test_topic_echo_multi_fields_nested (self ):
621634 with self .launch_topic_command (
@@ -631,6 +644,21 @@ def test_topic_echo_multi_fields_nested(self):
631644 ), timeout = 10 )
632645 assert topic_command .wait_for_shutdown (timeout = 10 )
633646
647+ @launch_testing .markers .retry_on_failure (times = 5 , delay = 1 )
648+ def test_topic_echo_multi_fields_array (self ):
649+ with self .launch_topic_command (
650+ arguments = ['echo' , '/arrays' , '--field' , 'float32_values_default.[2]' , '--field' ,
651+ 'string_values_default.[1]' ],
652+ ) as topic_command :
653+ assert topic_command .wait_for_output (functools .partial (
654+ launch_testing .tools .expect_output , expected_lines = [
655+ '-1.125' ,
656+ 'max value' ,
657+ '---' ,
658+ ], strict = True
659+ ), timeout = 10 )
660+ assert topic_command .wait_for_shutdown (timeout = 10 )
661+
634662 @launch_testing .markers .retry_on_failure (times = 5 , delay = 1 )
635663 def test_topic_echo_field_not_a_member (self ):
636664 with self .launch_topic_command (
@@ -643,6 +671,45 @@ def test_topic_echo_field_not_a_member(self):
643671 ), timeout = 10 )
644672 assert topic_command .wait_for_shutdown (timeout = 10 )
645673
674+ @launch_testing .markers .retry_on_failure (times = 5 , delay = 1 )
675+ def test_topic_echo_field_array_not_an_array (self ):
676+ with self .launch_topic_command (
677+ arguments = ['echo' , '/arrays' , '--field' , 'float32_values_default.[0].[0]' ],
678+ ) as topic_command :
679+ assert topic_command .wait_for_output (functools .partial (
680+ launch_testing .tools .expect_output , expected_lines = [
681+ "Invalid field 'float32_values_default.[0].[0]': invalid index to "
682+ 'scalar variable.' ,
683+ ], strict = True
684+ ), timeout = 10 )
685+ assert topic_command .wait_for_shutdown (timeout = 10 )
686+
687+ @launch_testing .markers .retry_on_failure (times = 5 , delay = 1 )
688+ def test_topic_echo_field_array_index_out_of_bounds (self ):
689+ with self .launch_topic_command (
690+ arguments = ['echo' , '/arrays' , '--field' , 'float32_values_default.[3]' ],
691+ ) as topic_command :
692+ assert topic_command .wait_for_output (functools .partial (
693+ launch_testing .tools .expect_output , expected_lines = [
694+ "Invalid field 'float32_values_default.[3]': index 3 is out of bounds "
695+ 'for axis 0 with size 3' ,
696+ ], strict = True
697+ ), timeout = 10 )
698+ assert topic_command .wait_for_shutdown (timeout = 10 )
699+
700+ @launch_testing .markers .retry_on_failure (times = 5 , delay = 1 )
701+ def test_topic_echo_field_array_no_index (self ):
702+ with self .launch_topic_command (
703+ arguments = ['echo' , '/arrays' , '--field' , 'float32_values_default.[abc]' ],
704+ ) as topic_command :
705+ assert topic_command .wait_for_output (functools .partial (
706+ launch_testing .tools .expect_output , expected_lines = [
707+ "Invalid field 'float32_values_default.[abc]': 'numpy.ndarray' object "
708+ "has no attribute '[abc]'" ,
709+ ], strict = True
710+ ), timeout = 10 )
711+ assert topic_command .wait_for_shutdown (timeout = 10 )
712+
646713 @launch_testing .markers .retry_on_failure (times = 5 , delay = 1 )
647714 def test_topic_echo_multi_fields_not_a_member (self ):
648715 with self .launch_topic_command (
0 commit comments