Test structstruct T1 {
int a;
};
class FooTest : public ::testing::TestWithParam<struct T1> {
// You can implement all the usual fixture class members here.
// To access the test parameter, call GetParam() from class
// TestWithParam<T>.
//在这里面可以实现fixture类的所有成员
protected:
FooTest() {
// You can do set-up work for each test here.
}
~FooTest() override {
// You can do clean-up work that doesn't throw exceptions here.
}
// If the constructor and destructor are not enough for setting up
// and cleaning up each test, you can define the following methods:
void SetUp() override {
// Code here will be called immediately after the constructor (right
// before each test).
}
void TearDown() override {
// Code here will be called immediately after each test (right
// before the destructor).
}
public:
struct T1 m_T;
};
//第二步
TEST_P(FooTest, DoesBlah) {
// Inside a test, access the test parameter with the GetParam() method
// of the TestWithParam<T> class:
//在测试中,使用TestWithParam <T>类的GetParam()方法访问测试参数:
T1 n = GetParam();
std::cout << m_T.a<<"----"<< n.a <<std::endl;
//...
}
//第三步
//第一个参数是前缀;第二个是类名;第三个是参数生成器
INSTANTIATE_TEST_SUITE_P(MyPrimeParamTest, FooTest, ::testing::Values(T1{1}));
int main(int argc, char** argv)
{
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}