谷歌测试:如何测试所有可能的 N 类型对?

Pie*_*tro 6 c++ googletest

此代码将对TestMultiTypes[float, double] 和 [char, int] 类型对运行测试:

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 );
Run Code Online (Sandbox Code Playgroud)

现在,假设我必须对所有可能的 N 类型对运行测试。我是否必须手动列出它们,还是有一种简单的方法可以让 Google Test 知道我想测试所有可能的 N 值的组合?

参考文献: C++ 多参数与 GTest TYPED_TEST