我想知道引數和期望在稍后實際匹配時是否超出范圍是否可以?像這樣:
struct Object
{
// ...
};
struct TestFixture : public testing::Test
{
MOCK_METHOD1(handle, void(Object obj));
};
TEST_F(TestFixture, Basic)
{
{
Object obj; // = get different obj
EXPECT_CALL(*this, handle(obj));
}
{
Object obj; // = get different obj
EXPECT_CALL(*this, handle(obj));
}
{
Object obj; // = get different obj
EXPECT_CALL(*this, handle(obj));
}
// call handle 3 times
}
所有 3 個obj變數都會超出范圍,還會EXPECT_CALL在那里創建某種區域變數嗎?這個測驗在 gtest 中可以嗎?謝謝。
uj5u.com熱心網友回復:
來自參考/matchers.html
除了
Ref(),這些匹配器會復制 value 以防它稍后被修改或破壞。
所以你很好。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/528208.html
上一篇:反應測驗庫用戶事件鍵盤不起作用
