资源简介
在编译目标目录下找到.\3rdparty\tinydnn\downloads\adb1c512e09ca2c7a6faef36f9c53e59\,其中adb1c512e09ca2c7a6faef36f9c53e59可能不一样,进入该目录,将该文件替换掉原来文件
代码片段和文件信息
#include “gtest/gtest.h“
#include “gmock/gmock.h“
// Simple test does not use gmock
TEST(Dummy foobar)
{
EXPECT_EQ(1 1);
}
// Real class we want to mock
class TeaBreak
{
public:
~TeaBreak() {}
// Return minutes taken to make the drinks
int morningTea()
{
return makeCoffee(true 1) +
makeCoffee(false 0.5) +
makeHerbalTea();
}
private:
virtual int makeCoffee(bool milk double sugars) = 0;
virtual int makeHerbalTea() = 0;
};
// Mock class
class MockTeaBreak : public TeaBreak
{
public:
MOCK_METHOD2(makeCoffee int(bool milk double sugars));
MOCK_METHOD0(makeHerbalTea int());
};
using ::testing::Return;
using ::testing::_;
// Mocked test
TEST(TeaBreakTest MorningTea)
{
MockTeaBreak teaBreak;
EXPECT_CALL(teaBreak makeCoffee(__))
.WillOnce(Return(2))
.WillOnce(Return(1));
EXPECT_CALL(teaBreak makeHerbalTea())
.WillOnce(Return(3));
EXPECT_LE(teaBreak.morningTea() 6);
}
评论
共有 条评论