vendredi 24 avril 2020

independent arguments to different TEST_P tests of the same fixture

I have a query- If I have a test fixture named - Calc. I have 4 tests:

TEST_F(Calc,Sub)

TEST_F(Calc,Div)

TEST_P(Calc,Add)

TEST_P(Calc,Mul)

If I supply arguments using INSTANTIATE_TEST_CASE_P, the same argument is taken by both the test cases. How do I differentiate arguments supplied ONLY to Add and ONLY to Mul?

TEST_P(Calc, Add){--do blah using GetParam()--}

INSTANTIATE_TEST_CASE_P(CalcAdd,
                         Calc,
                         ::testing::Values(2));

TEST_P(Calc,Mul){--do blah using GetParam()--}

INSTANTIATE_TEST_CASE_P(CalcMul,
                         Calc,
                         ::testing::Values(4));

Add and Mul test cases take both arguments while I just want add to take 2 and mul to take 4.

Please let me know if anyone finds a solution to this? Thanks a ton in advance.

Aucun commentaire:

Enregistrer un commentaire