From b031fc4819c621554d5874e41d22c712033b99f9 Mon Sep 17 00:00:00 2001 From: Jacob Perron Date: Fri, 26 Oct 2018 13:14:45 -0700 Subject: [PATCH] Add message fixture for DynamicArrayStaticArrayPrimitivesNested (#45) * Add message fixture for test_msgs/DynamicArrayStaticArrayPrimitivesNested * Add lint test to test_msgs and fix linter issues --- test_msgs/CMakeLists.txt | 5 ++ .../include/test_msgs/message_fixtures.hpp | 52 ++++++++++++------- test_msgs/package.xml | 1 + test_msgs/src/test_msgs/message_fixtures.py | 13 +++++ 4 files changed, 53 insertions(+), 18 deletions(-) diff --git a/test_msgs/CMakeLists.txt b/test_msgs/CMakeLists.txt index a49a5ab4..aa879842 100644 --- a/test_msgs/CMakeLists.txt +++ b/test_msgs/CMakeLists.txt @@ -41,6 +41,11 @@ rosidl_generate_interfaces(${PROJECT_NAME} ADD_LINTER_TESTS ) +if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + ament_lint_auto_find_test_dependencies() +endif() + if(DEFINED PYTHON_INSTALL_DIR) install(DIRECTORY src/test_msgs DESTINATION "${PYTHON_INSTALL_DIR}/") diff --git a/test_msgs/include/test_msgs/message_fixtures.hpp b/test_msgs/include/test_msgs/message_fixtures.hpp index e3566ced..0e9b0d77 100644 --- a/test_msgs/include/test_msgs/message_fixtures.hpp +++ b/test_msgs/include/test_msgs/message_fixtures.hpp @@ -26,6 +26,7 @@ #include "test_msgs/msg/dynamic_array_nested.hpp" #include "test_msgs/msg/dynamic_array_primitives.hpp" #include "test_msgs/msg/dynamic_array_primitives_nested.hpp" +#include "test_msgs/msg/dynamic_array_static_array_primitives_nested.hpp" #include "test_msgs/msg/empty.hpp" #include "test_msgs/msg/nested.hpp" #include "test_msgs/msg/primitives.hpp" @@ -137,16 +138,16 @@ get_messages_static_array_primitives() msg->float32_values = {{0.0f, 1.125f, -2.125f}}; msg->float64_values = {{0, 1.125, -2.125}}; msg->int8_values = {{ - 0, (std::numeric_limits::max)(), (std::numeric_limits::min)()}}; + 0, (std::numeric_limits::max)(), (std::numeric_limits::min)()}}; msg->uint8_values = {{0, (std::numeric_limits::max)(), 0}}; msg->int16_values = {{ - 0, (std::numeric_limits::max)(), (std::numeric_limits::min)()}}; + 0, (std::numeric_limits::max)(), (std::numeric_limits::min)()}}; msg->uint16_values = {{0, (std::numeric_limits::max)(), 0}}; msg->int32_values = {{ - static_cast(0), - (std::numeric_limits::max)(), - (std::numeric_limits::min)() - }}; + static_cast(0), + (std::numeric_limits::max)(), + (std::numeric_limits::min)() + }}; msg->uint32_values = {{0, (std::numeric_limits::max)(), 0}}; msg->int64_values[0] = 0; msg->int64_values[1] = (std::numeric_limits::max)(); @@ -208,17 +209,17 @@ get_messages_dynamic_array_primitives() msg->float32_values = {{0.0f, 1.125f, -2.125f}}; msg->float64_values = {{0, 1.125, -2.125}}; msg->int8_values = {{ - 0, (std::numeric_limits::max)(), (std::numeric_limits::min)()}}; + 0, (std::numeric_limits::max)(), (std::numeric_limits::min)()}}; msg->uint8_values = {{0, (std::numeric_limits::max)()}}; msg->int16_values = {{ - 0, (std::numeric_limits::max)(), (std::numeric_limits::min)()}}; + 0, (std::numeric_limits::max)(), (std::numeric_limits::min)()}}; msg->uint16_values = {{0, (std::numeric_limits::max)()}}; // The narrowing static cast is required to avoid build errors on Windows. msg->int32_values = {{ - static_cast(0), - (std::numeric_limits::max)(), - (std::numeric_limits::min)() - }}; + static_cast(0), + (std::numeric_limits::max)(), + (std::numeric_limits::min)() + }}; msg->uint32_values = {{0, (std::numeric_limits::max)()}}; msg->int64_values.resize(3); msg->int64_values[0] = 0; @@ -292,6 +293,21 @@ get_messages_dynamic_array_primitives_nested() return messages; } +std::vector +get_messages_dynamic_array_static_array_primitives_nested() +{ + std::vector messages; + + auto msg = std::make_shared(); + std::vector primitive_msgs = + get_messages_static_array_primitives(); + for (size_t i = 0; i < primitive_msgs.size(); ++i) { + msg->dynamic_array_static_array_primitive_values.push_back(*primitive_msgs[i]); + } + messages.push_back(msg); + return messages; +} + std::vector get_messages_bounded_array_primitives() { @@ -304,17 +320,17 @@ get_messages_bounded_array_primitives() msg->float32_values = {{0.0f, 1.125f, -2.125f}}; msg->float64_values = {{0, 1.125, -2.125}}; msg->int8_values = {{ - 0, (std::numeric_limits::max)(), (std::numeric_limits::min)()}}; + 0, (std::numeric_limits::max)(), (std::numeric_limits::min)()}}; msg->uint8_values = {{0, 1, (std::numeric_limits::max)()}}; msg->int16_values = {{ - 0, (std::numeric_limits::max)(), (std::numeric_limits::min)()}}; + 0, (std::numeric_limits::max)(), (std::numeric_limits::min)()}}; msg->uint16_values = {{0, 1, (std::numeric_limits::max)()}}; // The narrowing static cast is required to avoid build errors on Windows. msg->int32_values = {{ - static_cast(0), - (std::numeric_limits::max)(), - (std::numeric_limits::min)() - }}; + static_cast(0), + (std::numeric_limits::max)(), + (std::numeric_limits::min)() + }}; msg->uint32_values = {{0, 1, (std::numeric_limits::max)()}}; msg->int64_values.resize(3); msg->int64_values[0] = 0; diff --git a/test_msgs/package.xml b/test_msgs/package.xml index fdd98c48..90808df2 100644 --- a/test_msgs/package.xml +++ b/test_msgs/package.xml @@ -16,6 +16,7 @@ builtin_interfaces rosidl_default_runtime + ament_lint_auto ament_lint_common rosidl_interface_packages diff --git a/test_msgs/src/test_msgs/message_fixtures.py b/test_msgs/src/test_msgs/message_fixtures.py index 34acf1ae..38f6b492 100644 --- a/test_msgs/src/test_msgs/message_fixtures.py +++ b/test_msgs/src/test_msgs/message_fixtures.py @@ -18,6 +18,7 @@ from test_msgs.msg import DynamicArrayNested from test_msgs.msg import DynamicArrayPrimitives from test_msgs.msg import DynamicArrayPrimitivesNested +from test_msgs.msg import DynamicArrayStaticArrayPrimitivesNested from test_msgs.msg import Empty from test_msgs.msg import Nested from test_msgs.msg import Primitives @@ -273,6 +274,16 @@ def get_msg_dynamic_array_nested(): return [msg] +def get_msg_dynamic_array_static_array_primitives_nested(): + primitives_msgs = get_msg_static_array_primitives() + + msg = DynamicArrayStaticArrayPrimitivesNested() + for primitives_msg in primitives_msgs: + msg.dynamic_array_static_array_primitive_values.append(primitives_msg) + + return [msg] + + def get_msg_bounded_array_primitives(): msgs = [] @@ -328,6 +339,8 @@ def get_test_msg(message_name): msg = get_msg_dynamic_array_nested() elif 'DynamicArrayPrimitivesNested' == message_name: msg = get_msg_dynamic_array_primitives_nested() + elif 'DynamicArrayStaticArrayPrimitivesNested' == message_name: + msg = get_msg_dynamic_array_static_array_primitives_nested() elif 'BoundedArrayPrimitives' == message_name: msg = get_msg_bounded_array_primitives() elif 'BoundedArrayNested' == message_name: