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

code style only: wrap after open parenthesis if not in one line #435

Merged
merged 1 commit into from
Feb 4, 2020
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
9 changes: 6 additions & 3 deletions rosidl_generator_c/src/string_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ rosidl_generator_c__String__fini(rosidl_generator_c__String * str)
if (str->data) {
/* ensure that data and capacity values are consistent */
if (str->capacity <= 0) {
fprintf(stderr, "Unexpected condition: string capacity was zero for allocated data! "
fprintf(
stderr, "Unexpected condition: string capacity was zero for allocated data! "
"Exiting.\n");
exit(-1);
}
Expand All @@ -55,12 +56,14 @@ rosidl_generator_c__String__fini(rosidl_generator_c__String * str)
} else {
/* ensure that data, size, and capacity values are consistent */
if (0 != str->size) {
fprintf(stderr, "Unexpected condition: string size was non-zero for deallocated data! "
fprintf(
stderr, "Unexpected condition: string size was non-zero for deallocated data! "
"Exiting.\n");
exit(-1);
}
if (0 != str->capacity) {
fprintf(stderr, "Unexpected behavior: string capacity was non-zero for deallocated data! "
fprintf(
stderr, "Unexpected behavior: string capacity was non-zero for deallocated data! "
"Exiting.\n");
exit(-1);
}
Expand Down
9 changes: 6 additions & 3 deletions rosidl_generator_c/src/u16string_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ rosidl_generator_c__U16String__fini(rosidl_generator_c__U16String * str)
if (str->data) {
/* ensure that data and capacity values are consistent */
if (str->capacity <= 0) {
fprintf(stderr, "Unexpected condition: string capacity was zero for allocated data! "
fprintf(
stderr, "Unexpected condition: string capacity was zero for allocated data! "
"Exiting.\n");
exit(-1);
}
Expand All @@ -55,12 +56,14 @@ rosidl_generator_c__U16String__fini(rosidl_generator_c__U16String * str)
} else {
/* ensure that data, size, and capacity values are consistent */
if (0 != str->size) {
fprintf(stderr, "Unexpected condition: string size was non-zero for deallocated data! "
fprintf(
stderr, "Unexpected condition: string size was non-zero for deallocated data! "
"Exiting.\n");
exit(-1);
}
if (0 != str->capacity) {
fprintf(stderr, "Unexpected behavior: string capacity was non-zero for deallocated data! "
fprintf(
stderr, "Unexpected behavior: string capacity was non-zero for deallocated data! "
"Exiting.\n");
exit(-1);
}
Expand Down
126 changes: 84 additions & 42 deletions rosidl_generator_cpp/test/test_interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,33 +195,47 @@ void test_message_basic_types(rosidl_generator_cpp::msg::BasicTypes message)

void test_message_bounded(rosidl_generator_cpp::msg::BoundedSequences message)
{
TEST_BOUNDED_SEQUENCE_TYPES(message, bool_values, bool, SEQUENCE_SIZE, \
TEST_BOUNDED_SEQUENCE_TYPES(
message, bool_values, bool, SEQUENCE_SIZE, \
false, true)
TEST_BOUNDED_SEQUENCE_TYPES(message, char_values, unsigned char, SEQUENCE_SIZE, \
TEST_BOUNDED_SEQUENCE_TYPES(
message, char_values, unsigned char, SEQUENCE_SIZE, \
0, UINT8_MAX)
TEST_BOUNDED_SEQUENCE_TYPES(message, byte_values, uint8_t, SEQUENCE_SIZE, \
TEST_BOUNDED_SEQUENCE_TYPES(
message, byte_values, uint8_t, SEQUENCE_SIZE, \
0, UINT8_MAX)
TEST_BOUNDED_SEQUENCE_TYPES(message, float32_values, float, SEQUENCE_SIZE, \
TEST_BOUNDED_SEQUENCE_TYPES(
message, float32_values, float, SEQUENCE_SIZE, \
FLT_MIN, FLT_MAX)
TEST_BOUNDED_SEQUENCE_TYPES(message, float64_values, double, SEQUENCE_SIZE, \
TEST_BOUNDED_SEQUENCE_TYPES(
message, float64_values, double, SEQUENCE_SIZE, \
DBL_MIN, DBL_MAX)
TEST_BOUNDED_SEQUENCE_TYPES(message, int8_values, int8_t, SEQUENCE_SIZE, \
TEST_BOUNDED_SEQUENCE_TYPES(
message, int8_values, int8_t, SEQUENCE_SIZE, \
INT8_MIN, INT8_MAX)
TEST_BOUNDED_SEQUENCE_TYPES(message, uint8_values, uint8_t, SEQUENCE_SIZE, \
TEST_BOUNDED_SEQUENCE_TYPES(
message, uint8_values, uint8_t, SEQUENCE_SIZE, \
0, UINT8_MAX)
TEST_BOUNDED_SEQUENCE_TYPES(message, int16_values, int16_t, SEQUENCE_SIZE, \
TEST_BOUNDED_SEQUENCE_TYPES(
message, int16_values, int16_t, SEQUENCE_SIZE, \
INT16_MIN, INT16_MAX)
TEST_BOUNDED_SEQUENCE_TYPES(message, uint16_values, uint16_t, SEQUENCE_SIZE, \
TEST_BOUNDED_SEQUENCE_TYPES(
message, uint16_values, uint16_t, SEQUENCE_SIZE, \
0, UINT16_MAX)
TEST_BOUNDED_SEQUENCE_TYPES(message, int32_values, int32_t, SEQUENCE_SIZE, \
TEST_BOUNDED_SEQUENCE_TYPES(
message, int32_values, int32_t, SEQUENCE_SIZE, \
INT32_MIN, INT32_MAX)
TEST_BOUNDED_SEQUENCE_TYPES(message, uint32_values, uint32_t, SEQUENCE_SIZE, \
TEST_BOUNDED_SEQUENCE_TYPES(
message, uint32_values, uint32_t, SEQUENCE_SIZE, \
0, UINT32_MAX)
TEST_BOUNDED_SEQUENCE_TYPES(message, int64_values, int64_t, SEQUENCE_SIZE, \
TEST_BOUNDED_SEQUENCE_TYPES(
message, int64_values, int64_t, SEQUENCE_SIZE, \
INT64_MIN, INT64_MAX)
TEST_BOUNDED_SEQUENCE_TYPES(message, uint64_values, uint64_t, SEQUENCE_SIZE, \
TEST_BOUNDED_SEQUENCE_TYPES(
message, uint64_values, uint64_t, SEQUENCE_SIZE, \
0, UINT64_MAX)
TEST_BOUNDED_SEQUENCE_STRING(message, string_values, std::string, SEQUENCE_SIZE, \
TEST_BOUNDED_SEQUENCE_STRING(
message, string_values, std::string, SEQUENCE_SIZE, \
0, UINT32_MAX, 0, BOUNDED_STRING_LENGTH)
}

Expand All @@ -247,33 +261,47 @@ void test_message_bounded(rosidl_generator_cpp::msg::BoundedSequences message)

void test_message_unbounded(rosidl_generator_cpp::msg::UnboundedSequences message)
{
TEST_UNBOUNDED_SEQUENCE_TYPES(message, bool_values, bool, SEQUENCE_SIZE, \
TEST_UNBOUNDED_SEQUENCE_TYPES(
message, bool_values, bool, SEQUENCE_SIZE, \
false, true)
TEST_UNBOUNDED_SEQUENCE_TYPES(message, char_values, unsigned char, SEQUENCE_SIZE, \
TEST_UNBOUNDED_SEQUENCE_TYPES(
message, char_values, unsigned char, SEQUENCE_SIZE, \
0, UINT8_MAX)
TEST_UNBOUNDED_SEQUENCE_TYPES(message, byte_values, uint8_t, SEQUENCE_SIZE, \
TEST_UNBOUNDED_SEQUENCE_TYPES(
message, byte_values, uint8_t, SEQUENCE_SIZE, \
0, UINT8_MAX)
TEST_UNBOUNDED_SEQUENCE_TYPES(message, float32_values, float, SEQUENCE_SIZE, \
TEST_UNBOUNDED_SEQUENCE_TYPES(
message, float32_values, float, SEQUENCE_SIZE, \
FLT_MIN, FLT_MAX)
TEST_UNBOUNDED_SEQUENCE_TYPES(message, float64_values, double, SEQUENCE_SIZE, \
TEST_UNBOUNDED_SEQUENCE_TYPES(
message, float64_values, double, SEQUENCE_SIZE, \
DBL_MIN, DBL_MAX)
TEST_UNBOUNDED_SEQUENCE_TYPES(message, int8_values, int8_t, SEQUENCE_SIZE, \
TEST_UNBOUNDED_SEQUENCE_TYPES(
message, int8_values, int8_t, SEQUENCE_SIZE, \
INT8_MIN, INT8_MAX)
TEST_UNBOUNDED_SEQUENCE_TYPES(message, uint8_values, uint8_t, SEQUENCE_SIZE, \
TEST_UNBOUNDED_SEQUENCE_TYPES(
message, uint8_values, uint8_t, SEQUENCE_SIZE, \
0, UINT8_MAX)
TEST_UNBOUNDED_SEQUENCE_TYPES(message, int16_values, int16_t, SEQUENCE_SIZE, \
TEST_UNBOUNDED_SEQUENCE_TYPES(
message, int16_values, int16_t, SEQUENCE_SIZE, \
INT16_MIN, INT16_MAX)
TEST_UNBOUNDED_SEQUENCE_TYPES(message, uint16_values, uint16_t, SEQUENCE_SIZE, \
TEST_UNBOUNDED_SEQUENCE_TYPES(
message, uint16_values, uint16_t, SEQUENCE_SIZE, \
0, UINT16_MAX)
TEST_UNBOUNDED_SEQUENCE_TYPES(message, int32_values, int32_t, SEQUENCE_SIZE, \
TEST_UNBOUNDED_SEQUENCE_TYPES(
message, int32_values, int32_t, SEQUENCE_SIZE, \
INT32_MIN, INT32_MAX)
TEST_UNBOUNDED_SEQUENCE_TYPES(message, uint32_values, uint32_t, SEQUENCE_SIZE, \
TEST_UNBOUNDED_SEQUENCE_TYPES(
message, uint32_values, uint32_t, SEQUENCE_SIZE, \
0, UINT32_MAX)
TEST_UNBOUNDED_SEQUENCE_TYPES(message, int64_values, int64_t, SEQUENCE_SIZE, \
TEST_UNBOUNDED_SEQUENCE_TYPES(
message, int64_values, int64_t, SEQUENCE_SIZE, \
INT64_MIN, INT64_MAX)
TEST_UNBOUNDED_SEQUENCE_TYPES(message, uint64_values, uint64_t, SEQUENCE_SIZE, \
TEST_UNBOUNDED_SEQUENCE_TYPES(
message, uint64_values, uint64_t, SEQUENCE_SIZE, \
0, UINT64_MAX)
TEST_UNBOUNDED_SEQUENCE_STRING(message, string_values, std::string, SEQUENCE_SIZE, \
TEST_UNBOUNDED_SEQUENCE_STRING(
message, string_values, std::string, SEQUENCE_SIZE, \
0, UINT32_MAX, 0, UINT16_MAX)
}

Expand All @@ -287,31 +315,44 @@ void test_message_unbounded(rosidl_generator_cpp::msg::UnboundedSequences messag

void test_message_arrays(rosidl_generator_cpp::msg::Arrays message)
{
TEST_ARRAY_TYPES(message, bool_values, bool, ARRAY_SIZE, \
TEST_ARRAY_TYPES(
message, bool_values, bool, ARRAY_SIZE, \
false, true)
TEST_ARRAY_TYPES(message, char_values, unsigned char, ARRAY_SIZE, \
TEST_ARRAY_TYPES(
message, char_values, unsigned char, ARRAY_SIZE, \
0, UINT8_MAX)
TEST_ARRAY_TYPES(message, byte_values, uint8_t, ARRAY_SIZE, \
TEST_ARRAY_TYPES(
message, byte_values, uint8_t, ARRAY_SIZE, \
0, UINT8_MAX)
TEST_ARRAY_TYPES(message, float32_values, float, ARRAY_SIZE, \
TEST_ARRAY_TYPES(
message, float32_values, float, ARRAY_SIZE, \
FLT_MIN, FLT_MAX)
TEST_ARRAY_TYPES(message, float64_values, double, ARRAY_SIZE, \
TEST_ARRAY_TYPES(
message, float64_values, double, ARRAY_SIZE, \
DBL_MIN, DBL_MAX)
TEST_ARRAY_TYPES(message, int8_values, int8_t, ARRAY_SIZE, \
TEST_ARRAY_TYPES(
message, int8_values, int8_t, ARRAY_SIZE, \
INT8_MIN, INT8_MAX)
TEST_ARRAY_TYPES(message, uint8_values, uint8_t, ARRAY_SIZE, \
TEST_ARRAY_TYPES(
message, uint8_values, uint8_t, ARRAY_SIZE, \
0, UINT8_MAX)
TEST_ARRAY_TYPES(message, int16_values, int16_t, ARRAY_SIZE, \
TEST_ARRAY_TYPES(
message, int16_values, int16_t, ARRAY_SIZE, \
INT16_MIN, INT16_MAX)
TEST_ARRAY_TYPES(message, uint16_values, uint16_t, ARRAY_SIZE, \
TEST_ARRAY_TYPES(
message, uint16_values, uint16_t, ARRAY_SIZE, \
0, UINT16_MAX)
TEST_ARRAY_TYPES(message, int32_values, int32_t, ARRAY_SIZE, \
TEST_ARRAY_TYPES(
message, int32_values, int32_t, ARRAY_SIZE, \
INT32_MIN, INT32_MAX)
TEST_ARRAY_TYPES(message, uint32_values, uint32_t, ARRAY_SIZE, \
TEST_ARRAY_TYPES(
message, uint32_values, uint32_t, ARRAY_SIZE, \
0, UINT32_MAX)
TEST_ARRAY_TYPES(message, int64_values, int64_t, ARRAY_SIZE, \
TEST_ARRAY_TYPES(
message, int64_values, int64_t, ARRAY_SIZE, \
INT64_MIN, INT64_MAX)
TEST_ARRAY_TYPES(message, uint64_values, uint64_t, ARRAY_SIZE, \
TEST_ARRAY_TYPES(
message, uint64_values, uint64_t, ARRAY_SIZE, \
0, UINT64_MAX)
}

Expand Down Expand Up @@ -492,6 +533,7 @@ TEST(Test_messages, Test_wstring) {

TEST(Test_messages, Test_string_array_static) {
rosidl_generator_cpp::msg::Arrays message;
TEST_STATIC_ARRAY_STRING(message, string_values_default, std::string, ARRAY_SIZE, \
TEST_STATIC_ARRAY_STRING(
message, string_values_default, std::string, ARRAY_SIZE, \
0, UINT32_MAX, 0, UINT16_MAX)
}
34 changes: 20 additions & 14 deletions rosidl_generator_cpp/test/test_msg_initialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,25 +188,31 @@ TEST(Test_msg_initialization, skip_constructor) {
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif
ASSERT_TRUE(std::all_of(bounded->float32_values_default.begin(),
bounded->float32_values_default.end(), [](float i) {
uint32_t float32_bit_pattern = *reinterpret_cast<uint32_t *>(&i);
return 0xfefefefe == float32_bit_pattern;
}));
ASSERT_TRUE(std::all_of(bounded->float64_values_default.begin(),
bounded->float64_values_default.end(), [](double i) {
uint64_t float64_bit_pattern = *reinterpret_cast<uint64_t *>(&i);
return 0xfefefefefefefefe == float64_bit_pattern;
}));
ASSERT_TRUE(
std::all_of(
bounded->float32_values_default.begin(),
bounded->float32_values_default.end(), [](float i) {
uint32_t float32_bit_pattern = *reinterpret_cast<uint32_t *>(&i);
return 0xfefefefe == float32_bit_pattern;
}));
ASSERT_TRUE(
std::all_of(
bounded->float64_values_default.begin(),
bounded->float64_values_default.end(), [](double i) {
uint64_t float64_bit_pattern = *reinterpret_cast<uint64_t *>(&i);
return 0xfefefefefefefefe == float64_bit_pattern;
}));

#ifndef _WIN32
# pragma GCC diagnostic pop
#endif
ASSERT_EQ(0UL, bounded->float64_values_default.size());
ASSERT_EQ(0UL, bounded->float32_values_default.size());
ASSERT_EQ(0UL, bounded->float32_values.size());
ASSERT_TRUE(std::all_of(bounded->string_values_default.begin(),
bounded->string_values_default.end(), [](std::string i) {
return "" == i;
}));
ASSERT_TRUE(
std::all_of(
bounded->string_values_default.begin(),
bounded->string_values_default.end(), [](std::string i) {
return "" == i;
}));
}