summaryrefslogtreecommitdiffstats
path: root/googletest/test
diff options
context:
space:
mode:
authorBernhard Bauer <bauerb@chromium.org>2016-02-04 11:50:08 (GMT)
committerBernhard Bauer <bauerb@chromium.org>2017-09-04 14:46:31 (GMT)
commite7c9e80e63e5cdcd3252ed81c9d3dbf0a7fb6841 (patch)
tree26e4e942b928684de6131214dcdb2afa402c9be0 /googletest/test
parent7c6353d29a147cad1c904bf2957fd4ca2befe135 (diff)
downloadgoogletest-e7c9e80e63e5cdcd3252ed81c9d3dbf0a7fb6841.zip
googletest-e7c9e80e63e5cdcd3252ed81c9d3dbf0a7fb6841.tar.gz
googletest-e7c9e80e63e5cdcd3252ed81c9d3dbf0a7fb6841.tar.bz2
Allow macros inside of parametrized test names.
This allows doing things like TEST_P(TestFixture, MAYBE(TestName)) for nicer conditional test disabling.
Diffstat (limited to 'googletest/test')
-rw-r--r--googletest/test/gtest-param-test_test.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/googletest/test/gtest-param-test_test.cc b/googletest/test/gtest-param-test_test.cc
index 857f6c5..a6ecef6 100644
--- a/googletest/test/gtest-param-test_test.cc
+++ b/googletest/test/gtest-param-test_test.cc
@@ -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