Allow macros inside of parametrized test names.

This allows doing things like TEST_P(TestFixture, MAYBE(TestName)) for nicer conditional test disabling.
This commit is contained in:
Bernhard Bauer
2016-02-04 11:50:08 +00:00
parent 7c6353d29a
commit e7c9e80e63
3 changed files with 31 additions and 9 deletions

View File

@@ -809,6 +809,22 @@ TEST_P(NamingTest, TestsReportCorrectNamesAndParameters) {
INSTANTIATE_TEST_CASE_P(ZeroToFiveSequence, NamingTest, Range(0, 5));
// Tests that macros in test names are expanded correctly.
class MacroNamingTest : public TestWithParam<int> {};
#define PREFIX_WITH_FOO(test_name) FOO_##test_name
#define PREFIX_WITH_MACRO(test_name) Macro##test_name
TEST_P(PREFIX_WITH_MACRO(NamingTest), PREFIX_WITH_FOO(SomeTestName)) {
const ::testing::TestInfo* const test_info =
::testing::UnitTest::GetInstance()->current_test_info();
EXPECT_STREQ("FortyTwo/MacroNamingTest", test_info->test_case_name());
EXPECT_STREQ("FOO_SomeTestName", test_info->name());
}
INSTANTIATE_TEST_CASE_P(FortyTwo, MacroNamingTest, Values(42));
// Tests that user supplied custom parameter names are working correctly.
// Runs the test with a builtin helper method which uses PrintToString,
// as well as a custom function and custom functor to ensure all possible