Skip to content

Commit

Permalink
Rename gtest conflicting test macros
Browse files Browse the repository at this point in the history
bmqtst provides several gtest-like compatibility macros, but this
prevents us from using gtest or gmock directly because it uses the exact
same names as the test macros from that library. Since we want to
support at least using gmock in our tests, we rename them to avoid conflict.

Signed-off-by: Taylor Foxhall <[email protected]>
  • Loading branch information
hallfox committed Dec 4, 2024
1 parent 175e30d commit 73e2eda
Show file tree
Hide file tree
Showing 140 changed files with 2,187 additions and 2,094 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ static void test1_breathingTest()
fileManager,
bsl::cout,
bmqtst::TestHelperUtil::allocator());
ASSERT(dynamic_cast<JournalFileProcessor*>(cmdProcessor.get()) != 0);
BMQTST_ASSERT(dynamic_cast<JournalFileProcessor*>(cmdProcessor.get()) !=
0);
}

// ============================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -965,29 +965,29 @@ static void test12_printMessagesDetailsTest()
for (size_t i = 0; i < confirmedGUIDS.size(); i++) {
// Check Message type
size_t foundIdx = resultString.find(messageRecordCaption, startIdx);
ASSERT_D(messageRecordCaption, (foundIdx != bsl::string::npos));
ASSERT_D(messageRecordCaption, (foundIdx >= startIdx));
BMQTST_ASSERT_D(messageRecordCaption, (foundIdx != bsl::string::npos));
BMQTST_ASSERT_D(messageRecordCaption, (foundIdx >= startIdx));
startIdx = foundIdx + bsl::strlen(messageRecordCaption);

// Check GUID
bmqu::MemOutStream ss(bmqtst::TestHelperUtil::allocator());
outputGuidString(ss, confirmedGUIDS.at(i));
bsl::string guidStr(ss.str(), bmqtst::TestHelperUtil::allocator());
foundIdx = resultString.find(guidStr, startIdx);
ASSERT_D(guidStr, (foundIdx != bsl::string::npos));
ASSERT_D(guidStr, (foundIdx >= startIdx));
BMQTST_ASSERT_D(guidStr, (foundIdx != bsl::string::npos));
BMQTST_ASSERT_D(guidStr, (foundIdx >= startIdx));
startIdx = foundIdx + guidStr.length();

// Check Confirm type
foundIdx = resultString.find(confirmRecordCaption, startIdx);
ASSERT_D(confirmRecordCaption, (foundIdx != bsl::string::npos));
ASSERT_D(confirmRecordCaption, (foundIdx >= startIdx));
BMQTST_ASSERT_D(confirmRecordCaption, (foundIdx != bsl::string::npos));
BMQTST_ASSERT_D(confirmRecordCaption, (foundIdx >= startIdx));
startIdx = foundIdx + bsl::strlen(messageRecordCaption);

// Check Delete type
foundIdx = resultString.find(deleteRecordCaption, startIdx);
ASSERT_D(deleteRecordCaption, (foundIdx != bsl::string::npos));
ASSERT_D(deleteRecordCaption, (foundIdx >= startIdx));
BMQTST_ASSERT_D(deleteRecordCaption, (foundIdx != bsl::string::npos));
BMQTST_ASSERT_D(deleteRecordCaption, (foundIdx >= startIdx));
startIdx = foundIdx + bsl::strlen(messageRecordCaption);
}
}
Expand Down Expand Up @@ -1047,7 +1047,7 @@ static void test13_searchMessagesWithPayloadDumpTest()
MESSAGES,
k_NUM_MSGS,
messageOffsets);
ASSERT(pd != 0);
BMQTST_ASSERT(pd != 0);
BMQTST_ASSERT_GT(mfdData.fileSize(), 0ULL);
// Create data file iterator
DataFileIterator dataIt(&mfdData, fileHeader);
Expand Down Expand Up @@ -1115,17 +1115,17 @@ static void test13_searchMessagesWithPayloadDumpTest()
bsl::string guidStr(ss.str(), bmqtst::TestHelperUtil::allocator());
size_t foundIdx = resultString.find(guidStr, startIdx);

ASSERT_D(guidStr, (foundIdx != bsl::string::npos));
ASSERT_D(guidStr, (foundIdx >= startIdx));
BMQTST_ASSERT_D(guidStr, (foundIdx != bsl::string::npos));
BMQTST_ASSERT_D(guidStr, (foundIdx >= startIdx));

startIdx = foundIdx + guidStr.length();

// Check payload dump substring
bsl::string dumpStr = expectedPayloadSubstring[i];
foundIdx = resultString.find(dumpStr, startIdx);

ASSERT_D(dumpStr, (foundIdx != bsl::string::npos));
ASSERT_D(guidStr, (foundIdx >= startIdx));
BMQTST_ASSERT_D(dumpStr, (foundIdx != bsl::string::npos));
BMQTST_ASSERT_D(guidStr, (foundIdx >= startIdx));
startIdx = foundIdx + dumpStr.length();
}

Expand Down Expand Up @@ -1183,7 +1183,7 @@ static void test14_summaryTest()
"Number of outstanding messages: 2\nOutstanding ratio: 40% (2/5)\n";

bsl::string res(resultStream.str(), bmqtst::TestHelperUtil::allocator());
ASSERT(res.starts_with(expectedStream.str()));
BMQTST_ASSERT(res.starts_with(expectedStream.str()));
}

static void test15_timestampSearchTest()
Expand Down Expand Up @@ -1212,7 +1212,7 @@ static void test15_timestampSearchTest()
const bsls::Types::Uint64& ts)
{
BMQTST_ASSERT_GT(it.recordHeader().timestamp(), ts);
ASSERT(!it.isReverseMode());
BMQTST_ASSERT(!it.isReverseMode());
// Check previous record
it.flipDirection();
BMQTST_ASSERT_EQ(it.nextRecord(), 1);
Expand Down Expand Up @@ -1272,7 +1272,7 @@ static void test15_timestampSearchTest()
// specified iterator, which is initially backward
BMQTST_ASSERT_GT(journalFileIt.recordHeader().timestamp(), ts1);
journalFileIt.flipDirection();
ASSERT(journalFileIt.isReverseMode());
BMQTST_ASSERT(journalFileIt.isReverseMode());
BMQTST_ASSERT_EQ(m_bmqstoragetool::moveToLowerBound(&journalFileIt,
ts1),
1);
Expand All @@ -1282,7 +1282,7 @@ static void test15_timestampSearchTest()
// specified iterator, which is initially backward
BMQTST_ASSERT_LT(journalFileIt.recordHeader().timestamp(), ts2);
journalFileIt.flipDirection();
ASSERT(journalFileIt.isReverseMode());
BMQTST_ASSERT(journalFileIt.isReverseMode());
BMQTST_ASSERT_EQ(m_bmqstoragetool::moveToLowerBound(&journalFileIt,
ts2),
1);
Expand All @@ -1304,7 +1304,7 @@ static void test15_timestampSearchTest()
0);
BMQTST_ASSERT_EQ(journalFileIt.recordIndex(), k_NUM_RECORDS - 1);
BMQTST_ASSERT_LT(journalFileIt.recordHeader().timestamp(), ts);
ASSERT(!journalFileIt.isReverseMode());
BMQTST_ASSERT(!journalFileIt.isReverseMode());
}

{
Expand All @@ -1321,7 +1321,7 @@ static void test15_timestampSearchTest()
1);
BMQTST_ASSERT_EQ(journalFileIt.recordIndex(), 0U);
BMQTST_ASSERT_GT(journalFileIt.recordHeader().timestamp(), ts);
ASSERT(!journalFileIt.isReverseMode());
BMQTST_ASSERT(!journalFileIt.isReverseMode());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static void test1_breathingTest()
fileManager,
bsl::cout,
bmqtst::TestHelperUtil::allocator());
ASSERT(dynamic_cast<SearchResult*>(searchResult.get()) != 0);
BMQTST_ASSERT(dynamic_cast<SearchResult*>(searchResult.get()) != 0);
}

// ============================================================================
Expand Down
Loading

0 comments on commit 73e2eda

Please sign in to comment.