diff --git a/test_msgs/CMakeLists.txt b/test_msgs/CMakeLists.txt index 433833bc..1efe63e1 100644 --- a/test_msgs/CMakeLists.txt +++ b/test_msgs/CMakeLists.txt @@ -28,6 +28,9 @@ rosidl_generate_interfaces(test_msgs ${test_interface_files_ACTION_FILES} ${test_interface_files_IDL_FILES} "msg/Builtins.msg" + "msg/KeyedString.idl" + "msg/NonKeyedWithNestedKey.idl" + "msg/ComplexNestedKey.idl" "action/NestedMessage.action" DEPENDENCIES builtin_interfaces ADD_LINTER_TESTS diff --git a/test_msgs/include/test_msgs/message_fixtures.hpp b/test_msgs/include/test_msgs/message_fixtures.hpp index 45a5e1d3..50e311ef 100644 --- a/test_msgs/include/test_msgs/message_fixtures.hpp +++ b/test_msgs/include/test_msgs/message_fixtures.hpp @@ -29,11 +29,14 @@ #include "test_msgs/msg/bounded_plain_sequences.hpp" #include "test_msgs/msg/bounded_sequences.hpp" #include "test_msgs/msg/builtins.hpp" +#include "test_msgs/msg/complex_nested_key.hpp" #include "test_msgs/msg/constants.hpp" #include "test_msgs/msg/defaults.hpp" #include "test_msgs/msg/empty.hpp" +#include "test_msgs/msg/keyed_string.hpp" #include "test_msgs/msg/multi_nested.hpp" #include "test_msgs/msg/nested.hpp" +#include "test_msgs/msg/non_keyed_with_nested_key.hpp" #include "test_msgs/msg/strings.hpp" #include "test_msgs/msg/unbounded_sequences.hpp" #include "test_msgs/msg/w_strings.hpp" @@ -580,4 +583,52 @@ get_messages_wstrings() return messages; } +static inline std::vector +get_messages_keyed_string() +{ + std::vector messages; + { + auto msg = std::make_shared(); + msg->key = "key_1"; + msg->value = "value_1"; + messages.push_back(msg); + } + { + auto msg = std::make_shared(); + msg->key = "key_2"; + msg->value = "value_2"; + messages.push_back(msg); + } + return messages; +} + +static inline std::vector +get_messages_non_keyed_with_nested_key() +{ + std::vector messages; + auto keyed_string_msgs = get_messages_keyed_string(); + for (auto keyed_string_msg : keyed_string_msgs) { + auto msg = std::make_shared(); + msg->nested_data = *keyed_string_msg; + msg->some_int = -1; + messages.push_back(msg); + } + return messages; +} + +static inline std::vector +get_messages_complex_nested_key() +{ + std::vector messages; + auto non_keyed_with_nested_key_msgs = get_messages_non_keyed_with_nested_key(); + for (auto nested_msg : non_keyed_with_nested_key_msgs) { + auto msg = std::make_shared(); + msg->nested_keys = *nested_msg; + msg->uint32_key = 3u; + msg->float64_value = 1.125; + messages.push_back(msg); + } + return messages; +} + #endif // TEST_MSGS__MESSAGE_FIXTURES_HPP_ diff --git a/test_msgs/msg/ComplexNestedKey.idl b/test_msgs/msg/ComplexNestedKey.idl new file mode 100644 index 00000000..2ade00bc --- /dev/null +++ b/test_msgs/msg/ComplexNestedKey.idl @@ -0,0 +1,11 @@ +#include "test_msgs/msg/NonKeyedWithNestedKey.idl" + +module test_msgs{ + module msg { + struct ComplexNestedKey { + @key uint32 uint32_key; + @key test_msgs::msg::NonKeyedWithNestedKey nested_keys; + double float64_value; + }; + }; +}; diff --git a/test_msgs/msg/KeyedString.idl b/test_msgs/msg/KeyedString.idl new file mode 100644 index 00000000..d7f56965 --- /dev/null +++ b/test_msgs/msg/KeyedString.idl @@ -0,0 +1,8 @@ +module test_msgs{ + module msg { + struct KeyedString { + @key string key; + string value; + }; + }; +}; diff --git a/test_msgs/msg/NonKeyedWithNestedKey.idl b/test_msgs/msg/NonKeyedWithNestedKey.idl new file mode 100644 index 00000000..21ad30bd --- /dev/null +++ b/test_msgs/msg/NonKeyedWithNestedKey.idl @@ -0,0 +1,10 @@ +#include "test_msgs/msg/KeyedString.idl" + +module test_msgs{ + module msg { + struct NonKeyedWithNestedKey { + test_msgs::msg::KeyedString nested_data; + int32 some_int; + }; + }; +}; diff --git a/test_msgs/src/test_msgs/message_fixtures.py b/test_msgs/src/test_msgs/message_fixtures.py index 51175389..7bea1bad 100644 --- a/test_msgs/src/test_msgs/message_fixtures.py +++ b/test_msgs/src/test_msgs/message_fixtures.py @@ -17,11 +17,14 @@ from test_msgs.msg import BoundedPlainSequences from test_msgs.msg import BoundedSequences from test_msgs.msg import Builtins +from test_msgs.msg import ComplexNestedKey from test_msgs.msg import Constants from test_msgs.msg import Defaults from test_msgs.msg import Empty +from test_msgs.msg import KeyedString from test_msgs.msg import MultiNested from test_msgs.msg import Nested +from test_msgs.msg import NonKeyedWithNestedKey from test_msgs.msg import Strings from test_msgs.msg import UnboundedSequences from test_msgs.msg import WStrings @@ -395,6 +398,49 @@ def get_msg_wstrings(): return msgs +def get_msg_keyed_string(): + msgs = [] + + msg = KeyedString() + msg.key = 'key_1' + msg.value = 'value_1' + msgs.append(msg) + + msg = KeyedString() + msg.key = 'key_2' + msg.value = 'value_2' + msgs.append(msg) + + return msgs + + +def get_msg_non_keyed_with_nested_key(): + msgs = [] + + keyed_string_msgs = get_msg_keyed_string() + for keyed_string_msg in keyed_string_msgs: + msg = NonKeyedWithNestedKey() + msg.nested_data = keyed_string_msg + msg.some_int = -1 + msgs.append(msg) + + return msgs + + +def get_msg_complex_nested_key(): + msgs = [] + + non_keyed_with_nested_key_msgs = get_msg_non_keyed_with_nested_key() + for nested_msg in non_keyed_with_nested_key_msgs: + msg = ComplexNestedKey() + msg.nested_keys = nested_msg + msg.uint32_key = 3 + msg.float64_value = 1.125 + msgs.append(msg) + + return msgs + + def get_test_msg(message_name): if 'Builtins' == message_name: msg = get_msg_builtins() @@ -422,6 +468,12 @@ def get_test_msg(message_name): msg = get_msg_multi_nested() elif 'WStrings' == message_name: msg = get_msg_wstrings() + elif 'KeyedString' == message_name: + msg = get_msg_keyed_string() + elif 'NonKeyedWithNestedKey' == message_name: + msg = get_msg_non_keyed_with_nested_key() + elif 'ComplexNestedKey' == message_name: + msg = get_msg_complex_nested_key() else: raise NotImplementedError return msg