0

I am using gtest for unit testing. I have to call a lot to arrays to test. But I am not figuring out how i can pass N - number of variables in 'INSTANTIATE_TEST_CASE_P' to test.

I have simply created two arrays array1 and array2 and I am passing these two array in the field 'testing :: Values' of INSTANTIATE_TEST_CASE_P to test both of them and this test is working fine.

INSTANTIATE_TEST_CASE_P(
        ParameterizedTest,
        TestParam,
        testing :: Values(
                   array1,array2
                   ));

I want to create N-number of arrays like array1,array2,...,arrayN. But I do not know how i can pass them in the field testing :: Values of INSTANTIATE_TEST_CASE_P to test all of these N arrays.

Paul
  • 448
  • 1
  • 6
  • 14
  • Array of arrays? Or rather vector of vectors? Then you only pass a single argument. Or do you really need to pass all the arrays to a single call, can't you pass one array and call the function multiple times? – Some programmer dude Nov 07 '19 at 10:28

1 Answers1

1

The simplest solution is to gather all arrays in one class/struct, then have that struct passed as the parameter.

For anything more advanced, consult the "Parameter generator" section at https://github.com/google/googletest/blob/master/googletest/docs/advanced.md

Arne J
  • 415
  • 2
  • 9