This code will run the TestMultiTypes
test for both the [float, double] and [char, int] type pairs:
template <typename T>
class UtilsTestFixture2Types : public ::testing::Test {};
using Test2Types = ::testing::Types < std::pair<float, double>, std::pair<char, int> >;
TYPED_TEST_CASE_P( UtilsTestFixture2Types );
TYPED_TEST_P( UtilsTestFixture2Types, TestMultiTypes )
{
typename TypeParam::first_type p1 = 123;
typename TypeParam::second_type p2 = 234;
EXPECT_EQ( true, p2 < p1 ); // This will fail
}
REGISTER_TYPED_TEST_CASE_P( UtilsTestFixture2Types, TestMultiTypes );
INSTANTIATE_TYPED_TEST_CASE_P( Prefix, UtilsTestFixture2Types, Test2Types );
Now, suppose I have to run the test on all possible pairs of N types. Do I have to list them all manually, or is there a simple way to let Google Test know I want to test the combinations of all possible N values?
References: C++ Multiple parameters with GTest TYPED_TEST