GTEST:重置以前的GetParam()值

时间:2015-07-31 12:25:31

标签: c++ c googletest parameterized

我正在使用GTEST框架编写一个参数化测试。我想通过GetParam()重置传递给TEST_P的先前值。 在下面的代码中,gp.expected应返回0,1,0,但返回0,1,1

Code snipet:

class TestInput
{
public:
bool validate;
int  input;
int  expected;

TestInput(bool validate, int input, int expected)
{        
    this->validate = validate;
    this->input = input;
    this->expected = expected;
}    
};

    //[TRIMMED THE CODE] ...

   TEST_P(TestCase, nameTest)
   {
    TestInput gp = GetParam();
    printf("\n %d,", gp.expected); //Output 0,1,1 ???
   }

#define TestCase_TestData \
::testing::Values( \
TestInput(TRUE, 0, 0), \
TestInput(FALSE, 0, 1), \
TestInput(FALSE, 0, 0) \
)
INSTANTIATE_TEST_CASE_P(TestCase, TestCase, TestCase_TestData);

提前致谢

Pritish

0 个答案:

没有答案