如何合并"Values"和"Combine"?

How to combine "Values" and "Combine"?

我想向笛卡尔积添加一些特殊的值集。像这样:

INSTANTIATE_TEST_SUITE_P(Test, Test, 
    testing::Values(
        testing::Combine(
            testing::Values(1, 2, 3), 
            testing::Values("one", "two", "three")),
        testing::Values(std::make_tuple(12345, "big value"))));

但它不起作用。还有其他可行的方法吗?

你可以做两个实例化:

INSTANTIATE_TEST_SUITE_P(TestSanity, Test, 
    testing::Combine(
        testing::Values(1, 2, 3), 
        testing::Values("one", "two", "three")));

INSTANTIATE_TEST_SUITE_P(TestSpecial, Test, 
    testing::Values(std::make_tuple(12345, "big value")));

只有 Combine() 接受其他生成器作为输入,但这是不可取的。然而,这个问题可以通过使用两个单独的宏调用轻松解决,从您的测试中生成两个测试套件。 See it online.