本文整理汇总了C++中testing::IsEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ testing::IsEmpty方法的具体用法?C++ testing::IsEmpty怎么用?C++ testing::IsEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类testing
的用法示例。
在下文中一共展示了testing::IsEmpty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: msg
TEST_F(IRCSockTest, OnTextMessage) {
CMessage msg(":nick PRIVMSG #chan :hello");
m_pTestModule->eAction = CModule::HALT;
m_pTestSock->ReadLine(msg.ToString());
EXPECT_THAT(m_pTestModule->vsHooks, ElementsAre("OnChanTextMessage"));
EXPECT_THAT(m_pTestModule->vsMessages, ElementsAre(msg.ToString()));
EXPECT_THAT(m_pTestModule->vNetworks, ElementsAre(m_pTestNetwork));
EXPECT_THAT(m_pTestModule->vChannels, ElementsAre(m_pTestChan));
EXPECT_THAT(m_pTestClient->vsLines, IsEmpty()); // halt
m_pTestModule->eAction = CModule::CONTINUE;
m_pTestSock->ReadLine(msg.ToString());
EXPECT_THAT(m_pTestClient->vsLines, ElementsAre(msg.ToString()));
m_pTestClient->Reset();
m_pTestModule->Reset();
msg.Parse(":nick PRIVMSG me :hello");
m_pTestModule->eAction = CModule::HALT;
m_pTestSock->ReadLine(msg.ToString());
EXPECT_THAT(m_pTestModule->vsHooks, ElementsAre("OnPrivTextMessage"));
EXPECT_THAT(m_pTestModule->vsMessages, ElementsAre(msg.ToString()));
EXPECT_THAT(m_pTestModule->vNetworks, ElementsAre(m_pTestNetwork));
EXPECT_THAT(m_pTestModule->vChannels, ElementsAre(nullptr));
EXPECT_THAT(m_pTestClient->vsLines, IsEmpty()); // halt
m_pTestModule->eAction = CModule::CONTINUE;
m_pTestSock->ReadLine(msg.ToString());
EXPECT_THAT(m_pTestClient->vsLines, ElementsAre(msg.ToString()));
}
示例2: Reset
TEST_F(IRCSockTest, OnActionMessage) {
// 2 callbacks are called in row: OnCTCP, OnAction.
// If OnCTCP returns HALT, OnAction isn't called.
struct ActionModule : TestModule {
ActionModule() { Reset(); }
void Reset() {
Mock::VerifyAndClear(this);
EXPECT_CALL(*this, OnPrivCTCPMessage(_)).Times(0);
EXPECT_CALL(*this, OnChanCTCPMessage(_)).Times(0);
EXPECT_CALL(*this, OnPrivActionMessage(_)).Times(0);
EXPECT_CALL(*this, OnChanActionMessage(_)).Times(0);
TestModule::Reset();
}
MOCK_METHOD1(OnPrivCTCPMessage, EModRet(CCTCPMessage&));
MOCK_METHOD1(OnChanCTCPMessage, EModRet(CCTCPMessage&));
MOCK_METHOD1(OnPrivActionMessage, EModRet(CActionMessage&));
MOCK_METHOD1(OnChanActionMessage, EModRet(CActionMessage&));
};
ActionModule testModule;
CZNC::Get().GetModules().push_back(&testModule);
CChan* pExpectedChan = m_pTestChan;
CMessage msg(":nick PRIVMSG #chan :\001ACTION hello\001");
auto CON = Invoke([&](CMessage& m) {
EXPECT_EQ(m.ToString(), msg.ToString());
EXPECT_EQ(m.GetNetwork(), m_pTestNetwork);
EXPECT_EQ(m.GetChan(), pExpectedChan);
return CModule::CONTINUE;
});
auto HAL = Invoke([&](CMessage& m) {
EXPECT_EQ(m.ToString(), msg.ToString());
EXPECT_EQ(m.GetNetwork(), m_pTestNetwork);
EXPECT_EQ(m.GetChan(), pExpectedChan);
return CModule::HALT;
});
auto Reset = [&]() {
testModule.Reset();
m_pTestClient->Reset();
};
Reset();
{
InSequence seq;
EXPECT_CALL(testModule, OnChanCTCPMessage(_)).WillOnce(CON);
EXPECT_CALL(testModule, OnChanActionMessage(_)).WillOnce(CON);
}
m_pTestSock->ReadLine(msg.ToString());
EXPECT_THAT(m_pTestClient->vsLines, ElementsAre(msg.ToString()));
Reset();
{
InSequence seq;
EXPECT_CALL(testModule, OnChanCTCPMessage(_)).WillOnce(CON);
EXPECT_CALL(testModule, OnChanActionMessage(_)).WillOnce(HAL);
}
m_pTestSock->ReadLine(msg.ToString());
EXPECT_THAT(m_pTestClient->vsLines, IsEmpty());
Reset();
EXPECT_CALL(testModule, OnChanCTCPMessage(_)).WillOnce(HAL);
m_pTestSock->ReadLine(msg.ToString());
EXPECT_THAT(m_pTestClient->vsLines, IsEmpty());
msg.Parse(":nick PRIVMSG me :\001ACTION hello\001");
pExpectedChan = nullptr;
Reset();
{
InSequence seq;
EXPECT_CALL(testModule, OnPrivCTCPMessage(_)).WillOnce(CON);
EXPECT_CALL(testModule, OnPrivActionMessage(_)).WillOnce(CON);
}
m_pTestSock->ReadLine(msg.ToString());
EXPECT_THAT(m_pTestClient->vsLines, ElementsAre(msg.ToString()));
Reset();
{
InSequence seq;
EXPECT_CALL(testModule, OnPrivCTCPMessage(_)).WillOnce(CON);
EXPECT_CALL(testModule, OnPrivActionMessage(_)).WillOnce(HAL);
}
m_pTestSock->ReadLine(msg.ToString());
EXPECT_THAT(m_pTestClient->vsLines, IsEmpty());
Reset();
EXPECT_CALL(testModule, OnPrivCTCPMessage(_)).WillOnce(HAL);
m_pTestSock->ReadLine(msg.ToString());
EXPECT_THAT(m_pTestClient->vsLines, IsEmpty());
}