Merge pull request #2063 from mathbunnyru:master

PiperOrigin-RevId: 231434457
This commit is contained in:
Gennadiy Civil 2019-01-29 14:32:04 -05:00
commit 1f42ae7353
3 changed files with 18 additions and 31 deletions

View File

@ -46,9 +46,9 @@ matrix:
env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 NO_EXCEPTION=ON NO_RTTI=ON COMPILER_IS_GNUCXX=ON env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 NO_EXCEPTION=ON NO_RTTI=ON COMPILER_IS_GNUCXX=ON
- os: osx - os: osx
compiler: gcc compiler: gcc
env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 HOMEBREW_LOGS=~/homebrew-logs HOMEBREW_TEMP=~/homebrew-temp
- os: osx - os: osx
env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 HOMEBREW_LOGS=~/homebrew-logs HOMEBREW_TEMP=~/homebrew-temp
if: type != pull_request if: type != pull_request
# These are the install and build (script) phases for the most common entries in the matrix. They could be included # These are the install and build (script) phases for the most common entries in the matrix. They could be included

View File

@ -544,10 +544,11 @@ 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
// to specify a function or functor that generates custom test name suffixes // generator and an optional function or functor that generates custom test name
// based on the test parameters. The function should accept one argument of // suffixes based on the test parameters. Such a function or functor should
// type testing::TestParamInfo<class ParamType>, and return std::string. // accept one argument of 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()).
@ -556,15 +557,21 @@ 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 GTEST_EXPAND_(arg) arg
#define GTEST_GET_FIRST_(first, ...) first
#define GTEST_GET_SECOND_(first, second, ...) second
#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 GTEST_EXPAND_(GTEST_GET_FIRST_(__VA_ARGS__, DUMMY_PARAM_)); \
} \ } \
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 GTEST_EXPAND_(GTEST_GET_SECOND_( \
__VA_ARGS__)(info); \ __VA_ARGS__, \
::testing::internal::DefaultParamName<test_suite_name::ParamType>, \
DUMMY_PARAM_))(info); \
} \ } \
static int gtest_##prefix##test_suite_name##_dummy_ \ static int gtest_##prefix##test_suite_name##_dummy_ \
GTEST_ATTRIBUTE_UNUSED_ = \ GTEST_ATTRIBUTE_UNUSED_ = \

View File

@ -376,26 +376,6 @@ std::string DefaultParamName(const TestParamInfo<ParamType>& info) {
return name_stream.GetString(); return name_stream.GetString();
} }
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
//
// Parameterized test name overload helpers, which help the
// INSTANTIATE_TEST_SUITE_P macro choose between the default parameterized
// test name generator and user param name generator.
template <class ParamType, class ParamNameGenFunctor>
ParamNameGenFunctor GetParamNameGen(ParamNameGenFunctor func) {
return func;
}
template <class ParamType>
struct ParamNameGenFunc {
typedef std::string Type(const TestParamInfo<ParamType>&);
};
template <class ParamType>
typename ParamNameGenFunc<ParamType>::Type *GetParamNameGen() {
return DefaultParamName;
}
// 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
@ -500,7 +480,7 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
using ParamType = typename TestSuite::ParamType; using ParamType = typename TestSuite::ParamType;
// A function that returns an instance of appropriate generator type. // A function that returns an instance of appropriate generator type.
typedef ParamGenerator<ParamType>(GeneratorCreationFunc)(); typedef ParamGenerator<ParamType>(GeneratorCreationFunc)();
typedef typename ParamNameGenFunc<ParamType>::Type ParamNameGeneratorFunc; typedef std::string ParamNameGeneratorFunc(const TestParamInfo<ParamType>&);
explicit ParameterizedTestSuiteInfo(const char* name, explicit ParameterizedTestSuiteInfo(const char* name,
CodeLocation code_location) CodeLocation code_location)