Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
d30a37e7
Commit
d30a37e7
authored
Sep 21, 2017
by
Gennadiy Civil
Committed by
GitHub
Sep 21, 2017
Browse files
Revert "Allow macros inside of parametrized test names."
parent
ff679687
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
43 deletions
+9
-43
googletest/include/gtest/gtest-param-test.h
googletest/include/gtest/gtest-param-test.h
+6
-9
googletest/include/gtest/gtest-param-test.h.pump
googletest/include/gtest/gtest-param-test.h.pump
+3
-6
googletest/test/gtest-param-test_test.cc
googletest/test/gtest-param-test_test.cc
+0
-28
No files found.
googletest/include/gtest/gtest-param-test.h
View file @
d30a37e7
...
@@ -1375,10 +1375,7 @@ internal::CartesianProductHolder10<Generator1, Generator2, Generator3,
...
@@ -1375,10 +1375,7 @@ internal::CartesianProductHolder10<Generator1, Generator2, Generator3,
}
}
# endif // GTEST_HAS_COMBINE
# endif // GTEST_HAS_COMBINE
// Use a macro to stringify the test (case) name, because direct stringification
// does not work if one of the arguments is itself a macro
// (https://gcc.gnu.org/onlinedocs/cpp/Stringification.html).
# define GTEST_STRINGIFY_(name) #name
# define TEST_P(test_case_name, test_name) \
# define TEST_P(test_case_name, test_name) \
class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
...
@@ -1393,8 +1390,8 @@ internal::CartesianProductHolder10<Generator1, Generator2, Generator3,
...
@@ -1393,8 +1390,8 @@ internal::CartesianProductHolder10<Generator1, Generator2, Generator3,
#test_case_name, \
#test_case_name, \
::testing::internal::CodeLocation(\
::testing::internal::CodeLocation(\
__FILE__, __LINE__))->AddTestPattern(\
__FILE__, __LINE__))->AddTestPattern(\
GTEST_STRINGIFY_(
test_case_name
)
, \
#
test_case_name, \
GTEST_STRINGIFY_(
test_name
)
, \
#
test_name, \
new ::testing::internal::TestMetaFactory< \
new ::testing::internal::TestMetaFactory< \
GTEST_TEST_CLASS_NAME_(\
GTEST_TEST_CLASS_NAME_(\
test_case_name, test_name)>()); \
test_case_name, test_name)>()); \
...
@@ -1415,11 +1412,11 @@ internal::CartesianProductHolder10<Generator1, Generator2, Generator3,
...
@@ -1415,11 +1412,11 @@ internal::CartesianProductHolder10<Generator1, Generator2, Generator3,
// type testing::TestParamInfo<class ParamType>, and return std::string.
// type testing::TestParamInfo<class ParamType>, and return std::string.
//
//
// testing::PrintToStringParamName is a builtin test suffix generator that
// testing::PrintToStringParamName is a builtin test suffix generator that
// returns the value of testing::PrintToString(GetParam()).
// returns the value of testing::PrintToString(GetParam()). It does not work
// for std::string or C strings.
//
//
// Note: test names must be non-empty, unique, and may only contain ASCII
// Note: test names must be non-empty, unique, and may only contain ASCII
// alphanumeric characters or underscore. Because PrintToString adds quotes
// alphanumeric characters or underscore.
// to std::string and C strings, it won't work for these types.
# define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator, ...) \
# define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator, ...) \
::testing::internal::ParamGenerator<test_case_name::ParamType> \
::testing::internal::ParamGenerator<test_case_name::ParamType> \
...
...
googletest/include/gtest/gtest-param-test.h.pump
View file @
d30a37e7
...
@@ -441,10 +441,7 @@ internal::CartesianProductHolder$i<$for j, [[Generator$j]]> Combine(
...
@@ -441,10 +441,7 @@ internal::CartesianProductHolder$i<$for j, [[Generator$j]]> Combine(
]]
]]
# endif // GTEST_HAS_COMBINE
# endif // GTEST_HAS_COMBINE
// Use a macro to stringify the test (case) name, because direct stringification
// does not work if one of the arguments is itself a macro
// (https://gcc.gnu.org/onlinedocs/cpp/Stringification.html).
# define GTEST_STRINGIFY_(name) #name
# define TEST_P(test_case_name, test_name) \
# define TEST_P(test_case_name, test_name) \
class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
...
@@ -459,8 +456,8 @@ internal::CartesianProductHolder$i<$for j, [[Generator$j]]> Combine(
...
@@ -459,8 +456,8 @@ internal::CartesianProductHolder$i<$for j, [[Generator$j]]> Combine(
#test_case_name, \
#test_case_name, \
::testing::internal::CodeLocation(\
::testing::internal::CodeLocation(\
__FILE__, __LINE__))->AddTestPattern(\
__FILE__, __LINE__))->AddTestPattern(\
GTEST_STRINGIFY_(
test_case_name
)
, \
#
test_case_name, \
GTEST_STRINGIFY_(
test_name
)
, \
#
test_name, \
new ::testing::internal::TestMetaFactory< \
new ::testing::internal::TestMetaFactory< \
GTEST_TEST_CLASS_NAME_(\
GTEST_TEST_CLASS_NAME_(\
test_case_name, test_name)>()); \
test_case_name, test_name)>()); \
...
...
googletest/test/gtest-param-test_test.cc
View file @
d30a37e7
...
@@ -809,34 +809,6 @@ TEST_P(NamingTest, TestsReportCorrectNamesAndParameters) {
...
@@ -809,34 +809,6 @@ TEST_P(NamingTest, TestsReportCorrectNamesAndParameters) {
INSTANTIATE_TEST_CASE_P
(
ZeroToFiveSequence
,
NamingTest
,
Range
(
0
,
5
));
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 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
(
"FOO_SomeTestName"
,
test_info
->
name
());
}
// Tests that user supplied custom parameter names are working correctly.
// Tests that user supplied custom parameter names are working correctly.
// Runs the test with a builtin helper method which uses PrintToString,
// Runs the test with a builtin helper method which uses PrintToString,
// as well as a custom function and custom functor to ensure all possible
// as well as a custom function and custom functor to ensure all possible
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment