Skip to content

Commit

Permalink
Few fixups from self review
Browse files Browse the repository at this point in the history
  • Loading branch information
cjappl committed Jan 11, 2025
1 parent d8c4f2d commit 555c25c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions test/test_rtlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,13 @@ TYPED_TEST(RtLogTest, LoggerThreadDoesItsJob) {

TYPED_TEST(TruncatedRtLogTest, ErrorsReturnedFromLog) {
auto &logger = this->logger;
auto maxMessageLength = this->maxMessageLength;
EXPECT_EQ(logger.Log({ExampleLogLevel::Debug, ExampleLogRegion::Engine},
"Hello, %lu", 12ul),
rtlog::Status::Success);

EXPECT_EQ(logger.Log({ExampleLogLevel::Debug, ExampleLogRegion::Engine},
"Hello, %luxxxxxxxxxxxxxx", 123ul),
"Hello, %lu! xxxxxxxxxxx", 123ul),
rtlog::Status::Error_MessageTruncated);

// Inspect truncated message
Expand All @@ -206,7 +208,7 @@ TYPED_TEST(TruncatedRtLogTest, ErrorsReturnedFromLog) {
va_end(args);

EXPECT_STREQ(buffer.data(), "Hello, 12");
EXPECT_EQ(strlen(buffer.data()), this->maxMessageLength - 1);
EXPECT_EQ(strlen(buffer.data()), maxMessageLength - 1);
};
EXPECT_EQ(logger.PrintAndClearLogQueue(InspectLogMessage), 2);
}
Expand Down Expand Up @@ -241,11 +243,9 @@ TYPED_TEST(RtLogTest, LogReturnsSuccessOnNormalEnqueue) {

TYPED_TEST(TruncatedRtLogTest, LogHandlesLongMessageTruncation) {
auto &logger = this->logger;
auto maxMessageLength = this->maxMessageLength;
EXPECT_EQ(logger.Log({ExampleLogLevel::Debug, ExampleLogRegion::Engine},
FMT_STRING("Hello, {}"), 12ul),
rtlog::Status::Success);
EXPECT_EQ(logger.Log({ExampleLogLevel::Debug, ExampleLogRegion::Engine},
FMT_STRING("Hello, {}xxxxxxxxxxx"), 123ul),
FMT_STRING("Hello, {}! xxxxxxxxxxx"), 123l),
rtlog::Status::Error_MessageTruncated);

auto InspectLogMessage = [=](const ExampleLogData &data,
Expand All @@ -263,10 +263,10 @@ TYPED_TEST(TruncatedRtLogTest, LogHandlesLongMessageTruncation) {
va_end(args);

EXPECT_STREQ(buffer.data(), "Hello, 12");
EXPECT_EQ(strlen(buffer.data()), this->maxMessageLength - 1);
EXPECT_EQ(strlen(buffer.data()), maxMessageLength - 1);
};

EXPECT_EQ(logger.PrintAndClearLogQueue(InspectLogMessage), 2);
EXPECT_EQ(logger.PrintAndClearLogQueue(InspectLogMessage), 1);
}

TEST(LoggerTest, SingleWriterLogHandlesQueueFullError) {
Expand Down

0 comments on commit 555c25c

Please sign in to comment.