Skip to content

Commit

Permalink
Add message fixture for DynamicArrayStaticArrayPrimitivesNested (ros2…
Browse files Browse the repository at this point in the history
…/rcl_interfaces#45)

* Add message fixture for test_msgs/DynamicArrayStaticArrayPrimitivesNested

* Add lint test to test_msgs and fix linter issues
  • Loading branch information
jacobperron authored Oct 26, 2018
1 parent aad3f43 commit 860ec4f
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 18 deletions.
5 changes: 5 additions & 0 deletions test_msgs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}/")
Expand Down
52 changes: 34 additions & 18 deletions test_msgs/include/test_msgs/message_fixtures.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<int8_t>::max)(), (std::numeric_limits<int8_t>::min)()}};
0, (std::numeric_limits<int8_t>::max)(), (std::numeric_limits<int8_t>::min)()}};
msg->uint8_values = {{0, (std::numeric_limits<uint8_t>::max)(), 0}};
msg->int16_values = {{
0, (std::numeric_limits<int16_t>::max)(), (std::numeric_limits<int16_t>::min)()}};
0, (std::numeric_limits<int16_t>::max)(), (std::numeric_limits<int16_t>::min)()}};
msg->uint16_values = {{0, (std::numeric_limits<uint16_t>::max)(), 0}};
msg->int32_values = {{
static_cast<int32_t>(0),
(std::numeric_limits<int32_t>::max)(),
(std::numeric_limits<int32_t>::min)()
}};
static_cast<int32_t>(0),
(std::numeric_limits<int32_t>::max)(),
(std::numeric_limits<int32_t>::min)()
}};
msg->uint32_values = {{0, (std::numeric_limits<uint32_t>::max)(), 0}};
msg->int64_values[0] = 0;
msg->int64_values[1] = (std::numeric_limits<int64_t>::max)();
Expand Down Expand Up @@ -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<int8_t>::max)(), (std::numeric_limits<int8_t>::min)()}};
0, (std::numeric_limits<int8_t>::max)(), (std::numeric_limits<int8_t>::min)()}};
msg->uint8_values = {{0, (std::numeric_limits<uint8_t>::max)()}};
msg->int16_values = {{
0, (std::numeric_limits<int16_t>::max)(), (std::numeric_limits<int16_t>::min)()}};
0, (std::numeric_limits<int16_t>::max)(), (std::numeric_limits<int16_t>::min)()}};
msg->uint16_values = {{0, (std::numeric_limits<uint16_t>::max)()}};
// The narrowing static cast is required to avoid build errors on Windows.
msg->int32_values = {{
static_cast<int32_t>(0),
(std::numeric_limits<int32_t>::max)(),
(std::numeric_limits<int32_t>::min)()
}};
static_cast<int32_t>(0),
(std::numeric_limits<int32_t>::max)(),
(std::numeric_limits<int32_t>::min)()
}};
msg->uint32_values = {{0, (std::numeric_limits<uint32_t>::max)()}};
msg->int64_values.resize(3);
msg->int64_values[0] = 0;
Expand Down Expand Up @@ -292,6 +293,21 @@ get_messages_dynamic_array_primitives_nested()
return messages;
}

std::vector<test_msgs::msg::DynamicArrayStaticArrayPrimitivesNested::SharedPtr>
get_messages_dynamic_array_static_array_primitives_nested()
{
std::vector<test_msgs::msg::DynamicArrayStaticArrayPrimitivesNested::SharedPtr> messages;

auto msg = std::make_shared<test_msgs::msg::DynamicArrayStaticArrayPrimitivesNested>();
std::vector<test_msgs::msg::StaticArrayPrimitives::SharedPtr> 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<test_msgs::msg::BoundedArrayPrimitives::SharedPtr>
get_messages_bounded_array_primitives()
{
Expand All @@ -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<int8_t>::max)(), (std::numeric_limits<int8_t>::min)()}};
0, (std::numeric_limits<int8_t>::max)(), (std::numeric_limits<int8_t>::min)()}};
msg->uint8_values = {{0, 1, (std::numeric_limits<uint8_t>::max)()}};
msg->int16_values = {{
0, (std::numeric_limits<int16_t>::max)(), (std::numeric_limits<int16_t>::min)()}};
0, (std::numeric_limits<int16_t>::max)(), (std::numeric_limits<int16_t>::min)()}};
msg->uint16_values = {{0, 1, (std::numeric_limits<uint16_t>::max)()}};
// The narrowing static cast is required to avoid build errors on Windows.
msg->int32_values = {{
static_cast<int32_t>(0),
(std::numeric_limits<int32_t>::max)(),
(std::numeric_limits<int32_t>::min)()
}};
static_cast<int32_t>(0),
(std::numeric_limits<int32_t>::max)(),
(std::numeric_limits<int32_t>::min)()
}};
msg->uint32_values = {{0, 1, (std::numeric_limits<uint32_t>::max)()}};
msg->int64_values.resize(3);
msg->int64_values[0] = 0;
Expand Down
1 change: 1 addition & 0 deletions test_msgs/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<exec_depend>builtin_interfaces</exec_depend>
<exec_depend>rosidl_default_runtime</exec_depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<member_of_group>rosidl_interface_packages</member_of_group>
Expand Down
13 changes: 13 additions & 0 deletions test_msgs/src/test_msgs/message_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = []

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 860ec4f

Please sign in to comment.