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
7c4164bf
Commit
7c4164bf
authored
Jan 18, 2019
by
Ayaz Salikhov
Browse files
Fix INSTANTIATE_TEST_CASE_P with zero variadic arguments
parent
0adeadd2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
7 deletions
+32
-7
googletest/include/gtest/gtest-param-test.h
googletest/include/gtest/gtest-param-test.h
+7
-7
googletest/include/gtest/internal/gtest-param-util.h
googletest/include/gtest/internal/gtest-param-util.h
+25
-0
No files found.
googletest/include/gtest/gtest-param-test.h
View file @
7c4164bf
...
@@ -544,9 +544,9 @@ internal::CartesianProductHolder10<Generator1, Generator2, Generator3,
...
@@ -544,9 +544,9 @@ internal::CartesianProductHolder10<Generator1, Generator2, Generator3,
GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::AddToRegistry(); \
GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::AddToRegistry(); \
void GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::TestBody()
void GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::TestBody()
// The
optional
last argument to INSTANTIATE_TEST_SUITE_P allows the user
// The last argument to INSTANTIATE_TEST_SUITE_P allows the user
to specify generator
//
to specify a
function or functor that generates custom test name suffixes
//
and an optional
function or functor that generates custom test name suffixes
// based on the test parameters.
The
function should accept one argument of
// based on the test parameters.
Such a
function
or functor
should accept one argument of
// 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
...
@@ -556,15 +556,15 @@ internal::CartesianProductHolder10<Generator1, Generator2, Generator3,
...
@@ -556,15 +556,15 @@ internal::CartesianProductHolder10<Generator1, Generator2, Generator3,
// alphanumeric characters or underscore. Because PrintToString adds quotes
// alphanumeric characters or underscore. Because PrintToString adds quotes
// to std::string and C strings, it won't work for these types.
// to std::string and C strings, it won't work for these types.
#define INSTANTIATE_TEST_SUITE_P(prefix, test_suite_name,
generator, ...)
\
#define INSTANTIATE_TEST_SUITE_P(prefix, test_suite_name,
...)
\
static ::testing::internal::ParamGenerator<test_suite_name::ParamType> \
static ::testing::internal::ParamGenerator<test_suite_name::ParamType> \
gtest_##prefix##test_suite_name##_EvalGenerator_() { \
gtest_##prefix##test_suite_name##_EvalGenerator_() { \
return
generator;
\
return
VA_GETFIRST(__VA_ARGS__);
\
} \
} \
static ::std::string gtest_##prefix##test_suite_name##_EvalGenerateName_( \
static ::std::string gtest_##prefix##test_suite_name##_EvalGenerateName_( \
const ::testing::TestParamInfo<test_suite_name::ParamType>& info) { \
const ::testing::TestParamInfo<test_suite_name::ParamType>& info) { \
return ::testing::internal::
GetParamNameGen<test_suite_name::ParamType>(
\
return ::testing::internal::
CreateParamGenerator<
\
__VA_ARGS__)(info);
\
test_suite_name::ParamType>(VA_GETREST(
__VA_ARGS__
, 0)
)(info); \
} \
} \
static int gtest_##prefix##test_suite_name##_dummy_ \
static int gtest_##prefix##test_suite_name##_dummy_ \
GTEST_ATTRIBUTE_UNUSED_ = \
GTEST_ATTRIBUTE_UNUSED_ = \
...
...
googletest/include/gtest/internal/gtest-param-util.h
View file @
7c4164bf
...
@@ -41,6 +41,7 @@
...
@@ -41,6 +41,7 @@
#include <memory>
#include <memory>
#include <set>
#include <set>
#include <tuple>
#include <tuple>
#include <type_traits>
#include <utility>
#include <utility>
#include <vector>
#include <vector>
...
@@ -396,6 +397,30 @@ typename ParamNameGenFunc<ParamType>::Type *GetParamNameGen() {
...
@@ -396,6 +397,30 @@ typename ParamNameGenFunc<ParamType>::Type *GetParamNameGen() {
return
DefaultParamName
;
return
DefaultParamName
;
}
}
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
//
// Macroses allow to address an issue with zero element variadic macro
#define EXPAND(X) X
#define VA__GETFIRST(X, ...) X
#define VA_GETFIRST(...) EXPAND(VA__GETFIRST(__VA_ARGS__, 0))
#define VA_GETREST(X, ...) __VA_ARGS__
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
//
// Function is intended to swallow 0 as last argument and call GetParamNameGen
template
<
class
ParamType
>
auto
CreateParamGenerator
(
int
)
->
decltype
(
GetParamNameGen
<
ParamType
>
())
{
return
GetParamNameGen
<
ParamType
>
();
}
template
<
class
ParamType
,
class
Arg
>
auto
CreateParamGenerator
(
Arg
&&
arg
,
int
)
->
decltype
(
GetParamNameGen
<
ParamType
>
(
std
::
forward
<
Arg
>
(
arg
)))
{
return
GetParamNameGen
<
ParamType
>
(
std
::
forward
<
Arg
>
(
arg
));
}
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
//
//
// Stores a parameter value and later creates tests parameterized with that
// Stores a parameter value and later creates tests parameterized with that
...
...
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