Skip to content

Commit

Permalink
Uncrustify
Browse files Browse the repository at this point in the history
Signed-off-by: Eugenio Collado <[email protected]>
  • Loading branch information
EugenioCollado committed Dec 5, 2024
1 parent 375ff9d commit 91e53d8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/cpp/rtps/writer/BaseWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ uint32_t BaseWriter::calculate_max_payload_size(
if ((overhead + min_fragment_size) > max_data_size)
{
EPROSIMA_LOG_ERROR(RTPS_WRITER, "Datagram length '" << datagram_length << "' is too small." <<
"At least " << overhead << " bytes are needed to send a message. Fixing fragments to " << min_fragment_size << " bytes.");
"At least " << overhead << " bytes are needed to send a message. Fixing fragments to " <<
min_fragment_size << " bytes.");
return min_fragment_size;
}

Expand Down
8 changes: 4 additions & 4 deletions test/unittest/rtps/history/WriterHistoryTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ using namespace testing;
#define MAX_MESSAGE_SIZE 300

void cache_change_fragment(
uint32_t inline_qos_length)
uint32_t inline_qos_length)
{
uint32_t domain_id = 0;
uint32_t initial_reserved_caches = 10;
uint32_t max_message_size = MAX_MESSAGE_SIZE;
std::string max_message_size_str = std::to_string(max_message_size);

RTPSParticipantAttributes p_attr;
p_attr.properties.properties().emplace_back("fastdds.max_message_size", max_message_size_str);
p_attr.properties.properties().emplace_back("fastdds.max_message_size", max_message_size_str);
RTPSParticipant* participant = RTPSDomain::createParticipant(
domain_id, true, p_attr);

Expand All @@ -65,10 +65,10 @@ void cache_change_fragment(
change.writerGUID = bwriter->getGuid();
change.serializedPayload.length = 3 * max_allowed_payload_size; // Force to setFragmentSize
change.inline_qos.length = inline_qos_length;

history->add_change(&change);

auto result = change.getFragmentSize();
auto result = change.getFragmentSize();
std::cout << "Fragment size: " << result << std::endl;
ASSERT_NE(result, 0); // Fragment size should always be greater than 0
}
Expand Down
9 changes: 5 additions & 4 deletions test/unittest/rtps/writer/BaseWriterTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ namespace rtps {
using namespace testing;

void max_allowed_payload_size(
uint32_t max_message_size)
uint32_t max_message_size)
{
uint32_t domain_id = 0;
uint32_t initial_reserved_caches = 10;
std::string max_message_size_str = std::to_string(max_message_size);

RTPSParticipantAttributes p_attr;
p_attr.properties.properties().emplace_back("fastdds.max_message_size", max_message_size_str);
p_attr.properties.properties().emplace_back("fastdds.max_message_size", max_message_size_str);
RTPSParticipant* participant = RTPSDomain::createParticipant(
domain_id, true, p_attr);

Expand All @@ -58,15 +58,16 @@ void max_allowed_payload_size(
BaseWriter* bwriter = BaseWriter::downcast(writer);

auto result = bwriter->get_max_allowed_payload_size();
std::cout << "For max_message_size: " << max_message_size << " the max allowed payload size is: " << result << std::endl;
std::cout << "For max_message_size: " << max_message_size << " the max allowed payload size is: " << result <<
std::endl;

ASSERT_LE(result, max_message_size);
}

/**
* This test checks the get_max_allowed_payload_size() method of the BaseWriter.
* The method is called within a loop with different values of max_message_size.
* The test checks that the max_payload_size is always less than max_message_size,
* The test checks that the max_payload_size is always less than max_message_size,
* in other case it means an overflow has occurred.
*/
TEST(BaseWriterTests, calculate_max_payload_size_overflow)
Expand Down

0 comments on commit 91e53d8

Please sign in to comment.