GTest参数函数无法编译:在哪里修复?

时间:2018-10-02 09:37:24

标签: c++ parameters compilation googletest

我的代码:

#include <gtest/gtest.h>
bool IsEven(int i){return i%2==0;}
class IsEvenParamTest:public testing::TestWithParam<int>{};
INITIALIZE_TEST_CASE_P(MySuccess,IsEvenParamTest,testing::Range(2,6));
TEST_P(IsEvenParamTest, All){
    int n = GetParam();
    EXPECT_TRUE(IsEven(n));
}

g ++编译失败:

mytest.cpp:4:23: error: expected constructor, destructor, or type conversion before ‘(’ token
INITIALIZE_TEST_CASE_P(MySuccess,IsEvenParamTest,testing::Range(2,6));
                   ^

如何解决?

0 个答案:

没有答案