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 feac33c commit 7ac0b37
Show file tree
Hide file tree
Showing 37 changed files with 390 additions and 371 deletions.
231 changes: 119 additions & 112 deletions src/groups/bmq/bmqa/bmqa_abstractsession.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,135 +481,142 @@ static void test2_instanceInvariants()
const bmqa::AbstractSession::CloseQueueCallback closeQueueCallback;

// Base class instance
ASSERT_OPT_FAIL(concreteObj.start(dummyTimeInterval));
ASSERT_OPT_FAIL(concreteObj.startAsync(dummyTimeInterval));
ASSERT_OPT_FAIL(concreteObj.stop());
ASSERT_OPT_FAIL(concreteObj.stopAsync());
ASSERT_OPT_FAIL(concreteObj.finalizeStop());
ASSERT_OPT_FAIL(
BMQTST_ASSERT_OPT_FAIL(concreteObj.start(dummyTimeInterval));
BMQTST_ASSERT_OPT_FAIL(concreteObj.startAsync(dummyTimeInterval));
BMQTST_ASSERT_OPT_FAIL(concreteObj.stop());
BMQTST_ASSERT_OPT_FAIL(concreteObj.stopAsync());
BMQTST_ASSERT_OPT_FAIL(concreteObj.finalizeStop());
BMQTST_ASSERT_OPT_FAIL(
concreteObj.loadMessageEventBuilder(dummyMessageEventBuilderPtr));
ASSERT_OPT_FAIL(
BMQTST_ASSERT_OPT_FAIL(
concreteObj.loadConfirmEventBuilder(dummyConfirmEventBuilderPtr));
ASSERT_OPT_FAIL(
BMQTST_ASSERT_OPT_FAIL(
concreteObj.loadMessageProperties(dummyMessagePropertiesPtr));
ASSERT_OPT_FAIL(concreteObj.getQueueId(dummyQueueIdPtr, dummyUri));
ASSERT_OPT_FAIL(
BMQTST_ASSERT_OPT_FAIL(concreteObj.getQueueId(dummyQueueIdPtr, dummyUri));
BMQTST_ASSERT_OPT_FAIL(
concreteObj.getQueueId(dummyQueueIdPtr, dummyCorrelationId));
ASSERT_OPT_FAIL(concreteObj.openQueue(dummyQueueIdPtr,
dummyUri,
0,
dummyQueueOptions,
dummyTimeInterval));
ASSERT_OPT_FAIL(concreteObj.openQueueSync(dummyQueueIdPtr,
dummyUri,
0,
dummyQueueOptions,
dummyTimeInterval));
ASSERT_OPT_FAIL(concreteObj.openQueueAsync(dummyQueueIdPtr,
dummyUri,
0,
dummyQueueOptions,
dummyTimeInterval));
ASSERT_OPT_FAIL(concreteObj.openQueueAsync(dummyQueueIdPtr,
dummyUri,
0,
openQueueCallback,
dummyQueueOptions,
dummyTimeInterval));
ASSERT_OPT_FAIL(concreteObj.configureQueue(dummyQueueIdPtr,
dummyQueueOptions,
dummyTimeInterval));
ASSERT_OPT_FAIL(concreteObj.configureQueueSync(dummyQueueIdPtr,
dummyQueueOptions,
dummyTimeInterval));
ASSERT_OPT_FAIL(concreteObj.configureQueueAsync(dummyQueueIdPtr,
dummyQueueOptions,
dummyTimeInterval));
ASSERT_OPT_FAIL(concreteObj.configureQueueAsync(dummyQueueIdPtr,
dummyQueueOptions,
configureQueueCallback,
dummyTimeInterval));
ASSERT_OPT_FAIL(
BMQTST_ASSERT_OPT_FAIL(concreteObj.openQueue(dummyQueueIdPtr,
dummyUri,
0,
dummyQueueOptions,
dummyTimeInterval));
BMQTST_ASSERT_OPT_FAIL(concreteObj.openQueueSync(dummyQueueIdPtr,
dummyUri,
0,
dummyQueueOptions,
dummyTimeInterval));
BMQTST_ASSERT_OPT_FAIL(concreteObj.openQueueAsync(dummyQueueIdPtr,
dummyUri,
0,
dummyQueueOptions,
dummyTimeInterval));
BMQTST_ASSERT_OPT_FAIL(concreteObj.openQueueAsync(dummyQueueIdPtr,
dummyUri,
0,
openQueueCallback,
dummyQueueOptions,
dummyTimeInterval));
BMQTST_ASSERT_OPT_FAIL(concreteObj.configureQueue(dummyQueueIdPtr,
dummyQueueOptions,
dummyTimeInterval));
BMQTST_ASSERT_OPT_FAIL(concreteObj.configureQueueSync(dummyQueueIdPtr,
dummyQueueOptions,
dummyTimeInterval));
BMQTST_ASSERT_OPT_FAIL(concreteObj.configureQueueAsync(dummyQueueIdPtr,
dummyQueueOptions,
dummyTimeInterval));
BMQTST_ASSERT_OPT_FAIL(
concreteObj.configureQueueAsync(dummyQueueIdPtr,
dummyQueueOptions,
configureQueueCallback,
dummyTimeInterval));
BMQTST_ASSERT_OPT_FAIL(
concreteObj.closeQueue(dummyQueueIdPtr, dummyTimeInterval));
ASSERT_OPT_FAIL(
BMQTST_ASSERT_OPT_FAIL(
concreteObj.closeQueueSync(dummyQueueIdPtr, dummyTimeInterval));
ASSERT_OPT_FAIL(
BMQTST_ASSERT_OPT_FAIL(
concreteObj.closeQueueAsync(dummyQueueIdPtr, dummyTimeInterval));
ASSERT_OPT_FAIL(concreteObj.closeQueueAsync(dummyQueueIdPtr,
closeQueueCallback,
dummyTimeInterval));
ASSERT_OPT_FAIL(concreteObj.nextEvent(dummyTimeInterval));
ASSERT_OPT_FAIL(concreteObj.post(dummyMessageEvent));
ASSERT_OPT_FAIL(concreteObj.confirmMessage(dummyMessage));
ASSERT_OPT_FAIL(
BMQTST_ASSERT_OPT_FAIL(concreteObj.closeQueueAsync(dummyQueueIdPtr,
closeQueueCallback,
dummyTimeInterval));
BMQTST_ASSERT_OPT_FAIL(concreteObj.nextEvent(dummyTimeInterval));
BMQTST_ASSERT_OPT_FAIL(concreteObj.post(dummyMessageEvent));
BMQTST_ASSERT_OPT_FAIL(concreteObj.confirmMessage(dummyMessage));
BMQTST_ASSERT_OPT_FAIL(
concreteObj.confirmMessage(dummyMessageConfirmationCookie));
ASSERT_OPT_FAIL(concreteObj.confirmMessages(dummyConfirmEventBuilderPtr));
ASSERT_OPT_FAIL(concreteObj.configureMessageDumping(""));
BMQTST_ASSERT_OPT_FAIL(
concreteObj.confirmMessages(dummyConfirmEventBuilderPtr));
BMQTST_ASSERT_OPT_FAIL(concreteObj.configureMessageDumping(""));

// Derived instance
ASSERT_OPT_FAIL(testObj.start(dummyTimeInterval));
ASSERT_OPT_FAIL(testObj.startAsync(dummyTimeInterval));
ASSERT_OPT_FAIL(testObj.stop());
ASSERT_OPT_FAIL(testObj.stopAsync());
ASSERT_OPT_FAIL(testObj.finalizeStop());
ASSERT_OPT_FAIL(
BMQTST_ASSERT_OPT_FAIL(testObj.start(dummyTimeInterval));
BMQTST_ASSERT_OPT_FAIL(testObj.startAsync(dummyTimeInterval));
BMQTST_ASSERT_OPT_FAIL(testObj.stop());
BMQTST_ASSERT_OPT_FAIL(testObj.stopAsync());
BMQTST_ASSERT_OPT_FAIL(testObj.finalizeStop());
BMQTST_ASSERT_OPT_FAIL(
testObj.loadMessageEventBuilder(dummyMessageEventBuilderPtr));
ASSERT_OPT_FAIL(
BMQTST_ASSERT_OPT_FAIL(
testObj.loadConfirmEventBuilder(dummyConfirmEventBuilderPtr));
ASSERT_OPT_FAIL(testObj.loadMessageProperties(dummyMessagePropertiesPtr));
ASSERT_OPT_FAIL(testObj.getQueueId(dummyQueueIdPtr, dummyUri));
ASSERT_OPT_FAIL(testObj.getQueueId(dummyQueueIdPtr, dummyCorrelationId));
ASSERT_OPT_FAIL(testObj.openQueue(dummyQueueIdPtr,
dummyUri,
0,
dummyQueueOptions,
dummyTimeInterval));
ASSERT_OPT_FAIL(testObj.openQueueSync(dummyQueueIdPtr,
dummyUri,
0, // flags
dummyQueueOptions,
dummyTimeInterval));
ASSERT_OPT_FAIL(testObj.openQueueAsync(dummyQueueIdPtr,
dummyUri,
0,
dummyQueueOptions,
dummyTimeInterval));
ASSERT_OPT_FAIL(testObj.openQueueAsync(dummyQueueIdPtr,
dummyUri,
0,
openQueueCallback,
dummyQueueOptions,
dummyTimeInterval));
ASSERT_OPT_FAIL(testObj.configureQueue(dummyQueueIdPtr,
dummyQueueOptions,
dummyTimeInterval));
ASSERT_OPT_FAIL(testObj.configureQueueSync(dummyQueueIdPtr,
dummyQueueOptions,
dummyTimeInterval));
ASSERT_OPT_FAIL(testObj.configureQueueAsync(dummyQueueIdPtr,
dummyQueueOptions,
dummyTimeInterval));
ASSERT_OPT_FAIL(testObj.configureQueueAsync(dummyQueueIdPtr,
dummyQueueOptions,
configureQueueCallback,
dummyTimeInterval));
ASSERT_OPT_FAIL(testObj.closeQueue(dummyQueueIdPtr, dummyTimeInterval));
ASSERT_OPT_FAIL(
BMQTST_ASSERT_OPT_FAIL(
testObj.loadMessageProperties(dummyMessagePropertiesPtr));
BMQTST_ASSERT_OPT_FAIL(testObj.getQueueId(dummyQueueIdPtr, dummyUri));
BMQTST_ASSERT_OPT_FAIL(
testObj.getQueueId(dummyQueueIdPtr, dummyCorrelationId));
BMQTST_ASSERT_OPT_FAIL(testObj.openQueue(dummyQueueIdPtr,
dummyUri,
0,
dummyQueueOptions,
dummyTimeInterval));
BMQTST_ASSERT_OPT_FAIL(testObj.openQueueSync(dummyQueueIdPtr,
dummyUri,
0, // flags
dummyQueueOptions,
dummyTimeInterval));
BMQTST_ASSERT_OPT_FAIL(testObj.openQueueAsync(dummyQueueIdPtr,
dummyUri,
0,
dummyQueueOptions,
dummyTimeInterval));
BMQTST_ASSERT_OPT_FAIL(testObj.openQueueAsync(dummyQueueIdPtr,
dummyUri,
0,
openQueueCallback,
dummyQueueOptions,
dummyTimeInterval));
BMQTST_ASSERT_OPT_FAIL(testObj.configureQueue(dummyQueueIdPtr,
dummyQueueOptions,
dummyTimeInterval));
BMQTST_ASSERT_OPT_FAIL(testObj.configureQueueSync(dummyQueueIdPtr,
dummyQueueOptions,
dummyTimeInterval));
BMQTST_ASSERT_OPT_FAIL(testObj.configureQueueAsync(dummyQueueIdPtr,
dummyQueueOptions,
dummyTimeInterval));
BMQTST_ASSERT_OPT_FAIL(testObj.configureQueueAsync(dummyQueueIdPtr,
dummyQueueOptions,
configureQueueCallback,
dummyTimeInterval));
BMQTST_ASSERT_OPT_FAIL(
testObj.closeQueue(dummyQueueIdPtr, dummyTimeInterval));
BMQTST_ASSERT_OPT_FAIL(
testObj.closeQueueSync(dummyQueueIdPtr, dummyTimeInterval));
ASSERT_OPT_FAIL(
BMQTST_ASSERT_OPT_FAIL(
testObj.closeQueueAsync(dummyQueueIdPtr, dummyTimeInterval));
ASSERT_OPT_FAIL(testObj.closeQueueAsync(dummyQueueIdPtr,
closeQueueCallback,
dummyTimeInterval));
ASSERT_OPT_FAIL(testObj.nextEvent(dummyTimeInterval));
ASSERT_OPT_FAIL(testObj.post(dummyMessageEvent));
ASSERT_OPT_FAIL(testObj.confirmMessage(dummyMessage));
ASSERT_OPT_FAIL(testObj.confirmMessage(dummyMessageConfirmationCookie));
ASSERT_OPT_FAIL(testObj.confirmMessages(dummyConfirmEventBuilderPtr));
BMQTST_ASSERT_OPT_FAIL(testObj.closeQueueAsync(dummyQueueIdPtr,
closeQueueCallback,
dummyTimeInterval));
BMQTST_ASSERT_OPT_FAIL(testObj.nextEvent(dummyTimeInterval));
BMQTST_ASSERT_OPT_FAIL(testObj.post(dummyMessageEvent));
BMQTST_ASSERT_OPT_FAIL(testObj.confirmMessage(dummyMessage));
BMQTST_ASSERT_OPT_FAIL(
testObj.confirmMessage(dummyMessageConfirmationCookie));
BMQTST_ASSERT_OPT_FAIL(
testObj.confirmMessages(dummyConfirmEventBuilderPtr));

PV("Verify that overriden methods execute as intended");

ASSERT_OPT_PASS(testObj.configureMessageDumping(""));
BMQTST_ASSERT_OPT_PASS(testObj.configureMessageDumping(""));
BMQTST_ASSERT_EQ(testObj.configureMessageDumping(""), -1497);
}

Expand Down
40 changes: 20 additions & 20 deletions src/groups/bmq/bmqa/bmqa_message.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,36 +109,36 @@ static void test1_messageOnStackIsInvalid()

bmqa::Message msg;

ASSERT_SAFE_FAIL(msg.queueId());
ASSERT_SAFE_FAIL(msg.correlationId());
BMQTST_ASSERT_SAFE_FAIL(msg.queueId());
BMQTST_ASSERT_SAFE_FAIL(msg.correlationId());
#ifdef BMQ_ENABLE_MSG_GROUPID
ASSERT_SAFE_FAIL(msg.groupId());
BMQTST_ASSERT_SAFE_FAIL(msg.groupId());
#endif
ASSERT_SAFE_FAIL(msg.messageGUID());
ASSERT_SAFE_FAIL(msg.confirmationCookie());
ASSERT_SAFE_FAIL(msg.ackStatus());
ASSERT_SAFE_FAIL(msg.dataSize());
ASSERT_SAFE_FAIL(msg.hasProperties());
BMQTST_ASSERT_SAFE_FAIL(msg.messageGUID());
BMQTST_ASSERT_SAFE_FAIL(msg.confirmationCookie());
BMQTST_ASSERT_SAFE_FAIL(msg.ackStatus());
BMQTST_ASSERT_SAFE_FAIL(msg.dataSize());
BMQTST_ASSERT_SAFE_FAIL(msg.hasProperties());
#ifdef BMQ_ENABLE_MSG_GROUPID
ASSERT_SAFE_FAIL(msg.hasGroupId());
BMQTST_ASSERT_SAFE_FAIL(msg.hasGroupId());
#endif

PV("Cloned object - uninitialized");

bmqa::Message clone = msg.clone();

ASSERT_SAFE_FAIL(clone.queueId());
ASSERT_SAFE_FAIL(clone.correlationId());
BMQTST_ASSERT_SAFE_FAIL(clone.queueId());
BMQTST_ASSERT_SAFE_FAIL(clone.correlationId());
#ifdef BMQ_ENABLE_MSG_GROUPID
ASSERT_SAFE_FAIL(clone.groupId());
BMQTST_ASSERT_SAFE_FAIL(clone.groupId());
#endif
ASSERT_SAFE_FAIL(clone.messageGUID());
ASSERT_SAFE_FAIL(clone.confirmationCookie());
ASSERT_SAFE_FAIL(clone.ackStatus());
ASSERT_SAFE_FAIL(clone.dataSize());
ASSERT_SAFE_FAIL(clone.hasProperties());
BMQTST_ASSERT_SAFE_FAIL(clone.messageGUID());
BMQTST_ASSERT_SAFE_FAIL(clone.confirmationCookie());
BMQTST_ASSERT_SAFE_FAIL(clone.ackStatus());
BMQTST_ASSERT_SAFE_FAIL(clone.dataSize());
BMQTST_ASSERT_SAFE_FAIL(clone.hasProperties());
#ifdef BMQ_ENABLE_MSG_GROUPID
ASSERT_SAFE_FAIL(clone.hasGroupId());
BMQTST_ASSERT_SAFE_FAIL(clone.hasGroupId());
#endif
}

Expand Down Expand Up @@ -589,7 +589,7 @@ static void test4_subscriptionHandle()
bmqa::Message message = mIter.message();
PVVV("Message: " << message);

ASSERT_OPT_FAIL(message.subscriptionHandle());
BMQTST_ASSERT_OPT_FAIL(message.subscriptionHandle());
}

PV("ACK MESSAGE - FAIL")
Expand Down Expand Up @@ -626,7 +626,7 @@ static void test4_subscriptionHandle()
bmqa::Message message = mIter.message();
PVVV("Message: " << message);

ASSERT_OPT_FAIL(message.subscriptionHandle());
BMQTST_ASSERT_OPT_FAIL(message.subscriptionHandle());
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/groups/bmq/bmqa/bmqa_mocksession.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ static void test1_staticMethods()
{
PVV("Create Queue Session Event using Session Event Method");

ASSERT_FAIL(bmqa::MockSessionUtil::createSessionEvent(
BMQTST_ASSERT_FAIL(bmqa::MockSessionUtil::createSessionEvent(
bmqt::SessionEventType::e_QUEUE_OPEN_RESULT,
bmqt::CorrelationId(1),
0,
Expand Down Expand Up @@ -415,20 +415,20 @@ static void test2_call()
{
PVV("Incorrect call");
BMQA_EXPECT_CALL(mockSession, start()).returning(0);
ASSERT_FAIL(mockSession.stop());
BMQTST_ASSERT_FAIL(mockSession.stop());
BMQTST_ASSERT_EQ(mockSession.start(), 0);
}

{
PVV("Empty expected call queue");
ASSERT_FAIL(mockSession.startAsync());
BMQTST_ASSERT_FAIL(mockSession.startAsync());
}

{
PVV("Incorrect arguments");
BMQA_EXPECT_CALL(mockSession, startAsync(bsls::TimeInterval(10)))
.returning(0);
ASSERT_FAIL(mockSession.startAsync(bsls::TimeInterval(1)));
BMQTST_ASSERT_FAIL(mockSession.startAsync(bsls::TimeInterval(1)));
// To clear the expected queue.
BMQTST_ASSERT_EQ(mockSession.startAsync(bsls::TimeInterval(10)), 0);
}
Expand Down
16 changes: 8 additions & 8 deletions src/groups/bmq/bmqc/bmqc_array.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,22 +481,22 @@ static void test2_outOfBoundValidation()
const ObjType& constObj = obj;

// non-const
ASSERT_SAFE_FAIL(obj.front());
ASSERT_SAFE_FAIL(obj.back());
ASSERT_SAFE_FAIL(obj[0]);
BMQTST_ASSERT_SAFE_FAIL(obj.front());
BMQTST_ASSERT_SAFE_FAIL(obj.back());
BMQTST_ASSERT_SAFE_FAIL(obj[0]);

// const
ASSERT_SAFE_FAIL(constObj.front());
ASSERT_SAFE_FAIL(constObj.back());
ASSERT_SAFE_FAIL(constObj[0]);
BMQTST_ASSERT_SAFE_FAIL(constObj.front());
BMQTST_ASSERT_SAFE_FAIL(constObj.back());
BMQTST_ASSERT_SAFE_FAIL(constObj[0]);

// insert some items
const int k_NB_ITEMS = 5;
for (int i = 1; i <= k_NB_ITEMS; ++i) {
obj.push_back(TestType(i, bmqtst::TestHelperUtil::allocator()));
}

ASSERT_SAFE_FAIL(constObj[k_NB_ITEMS + 1]);
BMQTST_ASSERT_SAFE_FAIL(constObj[k_NB_ITEMS + 1]);

static_cast<void>(constObj);
}
Expand Down Expand Up @@ -871,7 +871,7 @@ static void test10_pushBackSelfRef()
for (int i = 0; i < k_SIZE; ++i) {
obj.push_back(TestType(i, bmqtst::TestHelperUtil::allocator()));
}
ASSERT_PASS(obj.push_back(obj[k_STATIC_LEN]));
BMQTST_ASSERT_PASS(obj.push_back(obj[k_STATIC_LEN]));
BMQTST_ASSERT_EQ(k_STATIC_LEN, obj[k_STATIC_LEN].valueAsInt());
BMQTST_ASSERT_EQ(k_STATIC_LEN, obj[k_SIZE].valueAsInt());
}
Expand Down
Loading

0 comments on commit 7ac0b37

Please sign in to comment.