Skip to content

Commit

Permalink
Refs #21537. Uncrustify.
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Company <[email protected]>
  • Loading branch information
MiguelCompany committed Sep 11, 2024
1 parent 030f4d4 commit 9c73e1d
Showing 1 changed file with 35 additions and 31 deletions.
66 changes: 35 additions & 31 deletions test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2324,60 +2324,64 @@ TEST(BuiltinDataSerializationTests, deserialization_of_big_parameters)
buffer[encapsulation_length + 3] = static_cast<octet>((big_parameter_plength >> 8) & 0xFF);

// Beware of semantically incorrect parameters
switch(pid)
switch (pid)
{
// The protocol version should be 2
case eprosima::fastdds::dds::PID_PROTOCOL_VERSION:
{
buffer[encapsulation_length + 4] = 0x02;
break;
}
break;

// The length of some string parameters should be lower than 256
case eprosima::fastdds::dds::PID_ENTITY_NAME:
case eprosima::fastdds::dds::PID_TYPE_NAME:
case eprosima::fastdds::dds::PID_TOPIC_NAME:
{
buffer[encapsulation_length + 2] = 0xFF;
buffer[encapsulation_length + 3] = 0x00;
break;
}
break;

// Data parameters should fill the whole parameter
case eprosima::fastdds::dds::PID_USER_DATA:
case eprosima::fastdds::dds::PID_TOPIC_DATA:
case eprosima::fastdds::dds::PID_GROUP_DATA:
{
constexpr uint16_t inner_data_length = big_parameter_plength - 4;
buffer[encapsulation_length + 4] = static_cast<octet>(inner_data_length & 0xFF);
buffer[encapsulation_length + 5] = static_cast<octet>((inner_data_length >> 8) & 0xFF);
}
break;
{
constexpr uint16_t inner_data_length = big_parameter_plength - 4;
buffer[encapsulation_length + 4] = static_cast<octet>(inner_data_length & 0xFF);
buffer[encapsulation_length + 5] = static_cast<octet>((inner_data_length >> 8) & 0xFF);
}
break;

// Custom content for partition
case eprosima::fastdds::dds::PID_PARTITION:
{
// Number of partitions (1)
buffer[encapsulation_length + 4] = 0x01;
buffer[encapsulation_length + 5] = 0x00;
buffer[encapsulation_length + 6] = 0x00;
buffer[encapsulation_length + 7] = 0x00;
// Partition name length (fills the rest of the parameter)
constexpr uint16_t partition_length = big_parameter_plength - 4 - 4;
buffer[encapsulation_length + 8] = static_cast<octet>(partition_length & 0xFF);
buffer[encapsulation_length + 9] = static_cast<octet>((partition_length >> 8) & 0xFF);
buffer[encapsulation_length + 10] = 0x00;
buffer[encapsulation_length + 11] = 0x00;
}
break;
{
// Number of partitions (1)
buffer[encapsulation_length + 4] = 0x01;
buffer[encapsulation_length + 5] = 0x00;
buffer[encapsulation_length + 6] = 0x00;
buffer[encapsulation_length + 7] = 0x00;
// Partition name length (fills the rest of the parameter)
constexpr uint16_t partition_length = big_parameter_plength - 4 - 4;
buffer[encapsulation_length + 8] = static_cast<octet>(partition_length & 0xFF);
buffer[encapsulation_length + 9] = static_cast<octet>((partition_length >> 8) & 0xFF);
buffer[encapsulation_length + 10] = 0x00;
buffer[encapsulation_length + 11] = 0x00;
}
break;

// Custom content for security tokens
case eprosima::fastdds::dds::PID_IDENTITY_TOKEN:
case eprosima::fastdds::dds::PID_PERMISSIONS_TOKEN:
{
// Content is a string + properties (0) + binary properties (0)
// Should fill the whole parameter
constexpr uint16_t token_string_length = big_parameter_plength - 4 - 4 - 4;
buffer[encapsulation_length + 4] = static_cast<octet>(token_string_length & 0xFF);
buffer[encapsulation_length + 5] = static_cast<octet>((token_string_length >> 8) & 0xFF);
}
break;
{
// Content is a string + properties (0) + binary properties (0)
// Should fill the whole parameter
constexpr uint16_t token_string_length = big_parameter_plength - 4 - 4 - 4;
buffer[encapsulation_length + 4] = static_cast<octet>(token_string_length & 0xFF);
buffer[encapsulation_length + 5] = static_cast<octet>((token_string_length >> 8) & 0xFF);
}
break;
}

// Deserialize a DATA(p)
Expand Down

0 comments on commit 9c73e1d

Please sign in to comment.