diff options
author | Gennadiy Civil <misterg@google.com> | 2018-03-13 11:13:58 -0400 |
---|---|---|
committer | Gennadiy Civil <misterg@google.com> | 2018-03-13 11:13:58 -0400 |
commit | 5461f63d012070cf9b3f88795ee8e337b00cbe36 (patch) | |
tree | 7b1caf78eda4b903eaa285517bb5bfdf2e3e7d34 /googletest/test | |
parent | af463c43ac22279239c1b8065ded7026b9224de1 (diff) | |
parent | f35fe6de3b25671099de0bf69b016eed3832dc9e (diff) | |
download | googletest-5461f63d012070cf9b3f88795ee8e337b00cbe36.tar.gz googletest-5461f63d012070cf9b3f88795ee8e337b00cbe36.zip |
Merge branch 'master' of https://github.com/google/googletest
Diffstat (limited to 'googletest/test')
-rw-r--r-- | googletest/test/gtest-param-test_test.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/googletest/test/gtest-param-test_test.cc b/googletest/test/gtest-param-test_test.cc index b21cb31f..adc4d1b5 100644 --- a/googletest/test/gtest-param-test_test.cc +++ b/googletest/test/gtest-param-test_test.cc @@ -848,6 +848,34 @@ 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("FooSomeTestName", test_info->name()); +} + +INSTANTIATE_TEST_CASE_P(FortyTwo, MacroNamingTest, Values(42)); + +// Tests the same thing for non-parametrized tests. +class MacroNamingTestNonParametrized : public ::testing::Test {}; + +TEST_F(PREFIX_WITH_MACRO(NamingTestNonParametrized), + PREFIX_WITH_FOO(SomeTestName)) { + const ::testing::TestInfo* const test_info = + ::testing::UnitTest::GetInstance()->current_test_info(); + + EXPECT_STREQ("MacroNamingTestNonParametrized", test_info->test_case_name()); + EXPECT_STREQ("FooSomeTestName", test_info->name()); +} + // 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 |