diff --git a/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp b/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp index 1f3c92b2323..1efc4af7792 100644 --- a/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp +++ b/test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp @@ -2324,60 +2324,64 @@ TEST(BuiltinDataSerializationTests, deserialization_of_big_parameters) buffer[encapsulation_length + 3] = static_cast((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(inner_data_length & 0xFF); - buffer[encapsulation_length + 5] = static_cast((inner_data_length >> 8) & 0xFF); - } - break; + { + constexpr uint16_t inner_data_length = big_parameter_plength - 4; + buffer[encapsulation_length + 4] = static_cast(inner_data_length & 0xFF); + buffer[encapsulation_length + 5] = static_cast((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(partition_length & 0xFF); - buffer[encapsulation_length + 9] = static_cast((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(partition_length & 0xFF); + buffer[encapsulation_length + 9] = static_cast((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(token_string_length & 0xFF); - buffer[encapsulation_length + 5] = static_cast((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(token_string_length & 0xFF); + buffer[encapsulation_length + 5] = static_cast((token_string_length >> 8) & 0xFF); + } + break; } // Deserialize a DATA(p)