From 3a677cd3beb613919ee7eadd229a3b808786ba09 Mon Sep 17 00:00:00 2001 From: Ezra Brooks Date: Mon, 6 Mar 2023 16:26:16 -0700 Subject: [PATCH] Minimal test --- .../test/internal/test_message_conversion.py | 18 ++++++++++++++++++ rosbridge_test_msgs/CMakeLists.txt | 1 + .../msg/TestNestedBoundedArray.msg | 1 + 3 files changed, 20 insertions(+) create mode 100644 rosbridge_test_msgs/msg/TestNestedBoundedArray.msg diff --git a/rosbridge_library/test/internal/test_message_conversion.py b/rosbridge_library/test/internal/test_message_conversion.py index 9ccba4f05..f837e6275 100755 --- a/rosbridge_library/test/internal/test_message_conversion.py +++ b/rosbridge_library/test/internal/test_message_conversion.py @@ -316,3 +316,21 @@ def test_float32_msg(rostype, data): ints = list(map(int, range(0, 16))) ret = test_float32_msg(rostype, ints) np.testing.assert_array_equal(ret, np.array(ints)) + + # Test a float32 array with a length with non-numeric characters in it + def test_float32_complexboundedarray(self): + def test_nestedboundedarray_msg(rostype, data): + msg = {"data": {"data": data}} + inst = ros_loader.get_message_instance(rostype) + c.populate_instance(msg, inst) + self.validate_instance(inst) + return inst.data + + for msgtype in ["TestNestedBoundedArray"]: + rostype = "rosbridge_test_msgs/" + msgtype + + # From List[float] + floats = list(map(float, range(0, 16))) + ret = test_nestedboundedarray_msg(rostype, floats) + + self.assertEqual(c._from_inst(ret, rostype), {"data": floats}) diff --git a/rosbridge_test_msgs/CMakeLists.txt b/rosbridge_test_msgs/CMakeLists.txt index e327c419d..4ef1e87df 100644 --- a/rosbridge_test_msgs/CMakeLists.txt +++ b/rosbridge_test_msgs/CMakeLists.txt @@ -20,6 +20,7 @@ rosidl_generate_interfaces(${PROJECT_NAME} msg/TestUInt8FixedSizeArray16.msg msg/TestFloat32Array.msg msg/TestFloat32BoundedArray.msg + msg/TestNestedBoundedArray.msg srv/AddTwoInts.srv srv/SendBytes.srv srv/TestArrayRequest.srv diff --git a/rosbridge_test_msgs/msg/TestNestedBoundedArray.msg b/rosbridge_test_msgs/msg/TestNestedBoundedArray.msg new file mode 100644 index 000000000..a35d82372 --- /dev/null +++ b/rosbridge_test_msgs/msg/TestNestedBoundedArray.msg @@ -0,0 +1 @@ +TestFloat32BoundedArray data