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

update test fixtures for char type #64

Merged
merged 2 commits into from
Mar 12, 2019
Merged
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
19 changes: 9 additions & 10 deletions test_msgs/include/test_msgs/message_fixtures.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ get_messages_primitives()
auto msg = std::make_shared<test_msgs::msg::Primitives>();
msg->bool_value = false;
msg->byte_value = 0;
msg->char_value = '\0';
msg->char_value = 0;
msg->float32_value = 0.0f;
msg->float64_value = 0;
msg->int8_value = 0;
Expand All @@ -71,7 +71,7 @@ get_messages_primitives()
auto msg = std::make_shared<test_msgs::msg::Primitives>();
msg->bool_value = true;
msg->byte_value = 255;
msg->char_value = '\x7f';
msg->char_value = 255;
msg->float32_value = 1.125f;
msg->float64_value = 1.125;
msg->int8_value = (std::numeric_limits<int8_t>::max)();
Expand All @@ -89,7 +89,7 @@ get_messages_primitives()
auto msg = std::make_shared<test_msgs::msg::Primitives>();
msg->bool_value = false;
msg->byte_value = 0;
msg->char_value = 0x0;
msg->char_value = 0;
msg->float32_value = -2.125f;
msg->float64_value = -2.125;
msg->int8_value = (std::numeric_limits<int8_t>::min)();
Expand All @@ -107,7 +107,7 @@ get_messages_primitives()
auto msg = std::make_shared<test_msgs::msg::Primitives>();
msg->bool_value = true;
msg->byte_value = 1;
msg->char_value = '\1';
msg->char_value = 1;
msg->float32_value = 1.0f;
msg->float64_value = 1;
msg->int8_value = 1;
Expand Down Expand Up @@ -136,7 +136,7 @@ get_messages_static_array_primitives()
auto msg = std::make_shared<test_msgs::msg::StaticArrayPrimitives>();
msg->bool_values = {{false, true, false}};
msg->byte_values = {{0, 0xff, 0}};
msg->char_values = {{'\0', '\x7f', '\0'}};
msg->char_values = {{0, 255, 0}};
msg->float32_values = {{0.0f, 1.125f, -2.125f}};
msg->float64_values = {{0, 1.125, -2.125}};
msg->int8_values = {{
Expand Down Expand Up @@ -206,7 +206,7 @@ get_messages_dynamic_array_primitives()
auto msg = std::make_shared<test_msgs::msg::DynamicArrayPrimitives>();
msg->bool_values = {true};
msg->byte_values = {0xff};
msg->char_values = {'\x7f'};
msg->char_values = {255};
msg->float32_values = {1.125f};
msg->float64_values = {1.125};
msg->int8_values = {(std::numeric_limits<int8_t>::max)()};
Expand All @@ -225,7 +225,7 @@ get_messages_dynamic_array_primitives()
auto msg = std::make_shared<test_msgs::msg::DynamicArrayPrimitives>();
msg->bool_values = {{false, true}};
msg->byte_values = {{0, 0xff}};
msg->char_values = {{'\0', '\x7f'}};
msg->char_values = {{0, 255}};
msg->float32_values = {{0.0f, 1.125f, -2.125f}};
msg->float64_values = {{0, 1.125, -2.125}};
msg->int8_values = {{
Expand Down Expand Up @@ -271,8 +271,7 @@ get_messages_dynamic_array_primitives()
for (size_t i = 0; i < size; ++i) {
msg->bool_values[i] = (i % 2 != 0) ? true : false;
msg->byte_values[i] = static_cast<uint8_t>(i);
// TODO(mikaelarguedas) only ascii chars supported across languages
msg->char_values[i] = static_cast<char>(i % (1 << 7));
msg->char_values[i] = static_cast<char>(i % (1 << 8));
msg->float32_values[i] = 1.125f * i;
msg->float64_values[i] = 1.125 * i;
msg->int8_values[i] = static_cast<int8_t>(i);
Expand Down Expand Up @@ -336,7 +335,7 @@ get_messages_bounded_array_primitives()
auto msg = std::make_shared<test_msgs::msg::BoundedArrayPrimitives>();
msg->bool_values = {{false, true, false}};
msg->byte_values = {{0, 1, 0xff}};
msg->char_values = {{'\0', '\1', '\x7f'}};
msg->char_values = {{0, 1, 255}};
msg->float32_values = {{0.0f, 1.125f, -2.125f}};
msg->float64_values = {{0, 1.125, -2.125}};
msg->int8_values = {{
Expand Down
8 changes: 4 additions & 4 deletions test_msgs/include/test_msgs/service_fixtures.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ get_services_primitives()
auto request = std::make_shared<test_msgs::srv::Primitives::Request>();
request->bool_value = false;
request->byte_value = 0;
request->char_value = '\0';
request->char_value = 0;
request->float32_value = 0.0f;
request->float64_value = 0.0;
request->int8_value = 0;
Expand All @@ -78,7 +78,7 @@ get_services_primitives()
auto reply = std::make_shared<test_msgs::srv::Primitives::Response>();
reply->bool_value = false;
reply->byte_value = 0;
reply->char_value = '\0';
reply->char_value = 0;
reply->float32_value = 0.0f;
reply->float64_value = 0.0;
reply->int8_value = 0;
Expand All @@ -96,7 +96,7 @@ get_services_primitives()
auto request = std::make_shared<test_msgs::srv::Primitives::Request>();
request->bool_value = true;
request->byte_value = 1;
request->char_value = 0x1;
request->char_value = 1;
request->float32_value = 1.125f;
request->float64_value = 1.11;
request->int8_value = 1;
Expand All @@ -115,7 +115,7 @@ get_services_primitives()
auto reply = std::make_shared<test_msgs::srv::Primitives::Response>();
reply->bool_value = true;
reply->byte_value = 11;
reply->char_value = 0x11;
reply->char_value = 11;
reply->float32_value = 11.125f;
reply->float64_value = 11.11;
reply->int8_value = 11;
Expand Down
19 changes: 9 additions & 10 deletions test_msgs/src/test_msgs/message_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def get_msg_primitives():
msg = Primitives()
msg.bool_value = False
msg.byte_value = bytes([0])
msg.char_value = '\x00'
msg.char_value = 0
msg.float32_value = float(0.0)
msg.float64_value = float(0.0)
msg.int8_value = 0
Expand All @@ -73,7 +73,7 @@ def get_msg_primitives():
msg = Primitives()
msg.bool_value = True
msg.byte_value = bytes([255])
msg.char_value = '\x7f'
msg.char_value = 255
msg.float32_value = 1.125
msg.float64_value = 1.125
msg.int8_value = 127
Expand All @@ -90,7 +90,7 @@ def get_msg_primitives():
msg = Primitives()
msg.bool_value = False
msg.byte_value = bytes([0])
msg.char_value = '\x00'
msg.char_value = 0
msg.float32_value = -2.125
msg.float64_value = -2.125
msg.int8_value = -128
Expand All @@ -107,7 +107,7 @@ def get_msg_primitives():
msg = Primitives()
msg.bool_value = True
msg.byte_value = bytes([1])
msg.char_value = '\x01'
msg.char_value = 1
msg.float32_value = float(1.0)
msg.float64_value = float(1.0)
msg.int8_value = 1
Expand Down Expand Up @@ -144,7 +144,7 @@ def get_msg_static_array_primitives():
msgs = []
msg = StaticArrayPrimitives()
msg.bool_values = [False, True, False]
msg.char_values = ['\0', '\x7f', '\x00']
msg.char_values = [0, 255, 0]
msg.byte_values = [bytes([0]), bytes([255]), bytes([0])]
msg.float32_values = [0.0, 1.125, -2.125]
msg.float64_values = [0.0, 1.125, -2.125]
Expand Down Expand Up @@ -207,7 +207,7 @@ def get_msg_dynamic_array_primitives():
msg = DynamicArrayPrimitives()
msg.bool_values = [True]
msg.byte_values = [bytes([255])]
msg.char_values = ['\x7f']
msg.char_values = [255]
msg.float32_values = [1.125]
msg.float64_values = [1.125]
msg.int8_values = [127]
Expand All @@ -225,7 +225,7 @@ def get_msg_dynamic_array_primitives():
msg = DynamicArrayPrimitives()
msg.bool_values = [False, True]
msg.byte_values = [bytes([0]), bytes([255])]
msg.char_values = ['\0', '\x7f']
msg.char_values = [0, 255]
msg.float32_values = [0.0, 1.125, -2.125]
msg.float64_values = [0.0, 1.125, -2.125]
msg.int8_values = [0, 127, -128]
Expand All @@ -245,8 +245,7 @@ def get_msg_dynamic_array_primitives():
msg = DynamicArrayPrimitives()
msg.bool_values = [i % 2 != 0 for i in range(size)]
msg.byte_values = [bytes([i % (1 << 8)]) for i in range(size)]
# TODO(mikaelarguedas) only ascii chars supported across languages
msg.char_values = [chr(i % (1 << 7)) for i in range(size)]
msg.char_values = [i % (1 << 8) for i in range(size)]
msg.float32_values = [float(1.125 * i) for i in range(size)]
msg.float64_values = [1.125 * i for i in range(size)]
msg.int8_values = [int_from_uint(i, 8) for i in range(size)]
Expand Down Expand Up @@ -302,7 +301,7 @@ def get_msg_bounded_array_primitives():
msg = BoundedArrayPrimitives()
msg.bool_values = [False, True, False]
msg.byte_values = [bytes([0]), bytes([1]), bytes([255])]
msg.char_values = ['\0', '\1', '\x7f']
msg.char_values = [0, 1, 255]
msg.float32_values = [0.0, 1.125, -2.125]
msg.float64_values = [0.0, 1.125, -2.125]
msg.int8_values = [0, 127, -128]
Expand Down
8 changes: 4 additions & 4 deletions test_msgs/src/test_msgs/service_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get_msg_primitives():
req = Primitives.Request()
req.bool_value = False
req.byte_value = bytes([0])
req.char_value = '\x00'
req.char_value = 0
req.float32_value = float(0.0)
req.float64_value = float(0.0)
req.int8_value = 0
Expand All @@ -43,7 +43,7 @@ def get_msg_primitives():
resp = Primitives.Response()
resp.bool_value = False
resp.byte_value = bytes([0])
resp.char_value = '\x00'
resp.char_value = 0
resp.float32_value = float(0.0)
resp.float64_value = float(0.0)
resp.int8_value = 0
Expand All @@ -60,7 +60,7 @@ def get_msg_primitives():
req = Primitives.Request()
req.bool_value = True
req.byte_value = bytes([1])
req.char_value = '\x01'
req.char_value = 1
req.float32_value = float(1.125)
req.float64_value = float(1.11)
req.int8_value = 1
Expand All @@ -78,7 +78,7 @@ def get_msg_primitives():
resp = Primitives.Response()
resp.bool_value = True
resp.byte_value = bytes([11])
resp.char_value = '\x11'
resp.char_value = 11
resp.float32_value = float(11.125)
resp.float64_value = float(11.11)
resp.int8_value = 11
Expand Down