Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add messages with key to test_msgs #162

Open
wants to merge 4 commits into
base: rolling
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions test_msgs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 51 additions & 0 deletions test_msgs/include/test_msgs/message_fixtures.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -580,4 +583,52 @@ get_messages_wstrings()
return messages;
}

static inline std::vector<test_msgs::msg::KeyedString::SharedPtr>
get_messages_keyed_string()
{
std::vector<test_msgs::msg::KeyedString::SharedPtr> messages;
{
auto msg = std::make_shared<test_msgs::msg::KeyedString>();
msg->key = "key_1";
msg->value = "value_1";
messages.push_back(msg);
}
{
auto msg = std::make_shared<test_msgs::msg::KeyedString>();
msg->key = "key_2";
msg->value = "value_2";
messages.push_back(msg);
}
return messages;
}

static inline std::vector<test_msgs::msg::NonKeyedWithNestedKey::SharedPtr>
get_messages_non_keyed_with_nested_key()
{
std::vector<test_msgs::msg::NonKeyedWithNestedKey::SharedPtr> messages;
auto keyed_string_msgs = get_messages_keyed_string();
for (auto keyed_string_msg : keyed_string_msgs) {
auto msg = std::make_shared<test_msgs::msg::NonKeyedWithNestedKey>();
msg->nested_data = *keyed_string_msg;
msg->some_int = -1;
messages.push_back(msg);
}
return messages;
}

static inline std::vector<test_msgs::msg::ComplexNestedKey::SharedPtr>
get_messages_complex_nested_key()
{
std::vector<test_msgs::msg::ComplexNestedKey::SharedPtr> 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<test_msgs::msg::ComplexNestedKey>();
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_
11 changes: 11 additions & 0 deletions test_msgs/msg/ComplexNestedKey.idl
Original file line number Diff line number Diff line change
@@ -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;
};
};
};
8 changes: 8 additions & 0 deletions test_msgs/msg/KeyedString.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module test_msgs{
module msg {
struct KeyedString {
@key string key;
string value;
};
};
};
10 changes: 10 additions & 0 deletions test_msgs/msg/NonKeyedWithNestedKey.idl
Original file line number Diff line number Diff line change
@@ -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;
};
};
};
52 changes: 52 additions & 0 deletions test_msgs/src/test_msgs/message_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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