diff --git a/.travis.yml b/.travis.yml index 23d55b23..3c52e78c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,7 +40,7 @@ matrix: - os: linux group: deprecated-2017Q4 compiler: clang - env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 -Wgnu-zero-variadic-macro-arguments" + env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 - os: linux compiler: clang env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 NO_EXCEPTION=ON NO_RTTI=ON COMPILER_IS_GNUCXX=ON diff --git a/googletest/docs/advanced.md b/googletest/docs/advanced.md index acb7f240..dbe6694a 100644 --- a/googletest/docs/advanced.md +++ b/googletest/docs/advanced.md @@ -1198,7 +1198,7 @@ also supports per-test-suite set-up/tear-down. To use it: 1. Outside your test fixture class (typically just below it), define those member variables, optionally giving them initial values. 1. In the same test fixture class, define a `static void SetUpTestSuite()` - function (remember not to spell it as **`SetupTestSuite`** with a small `u`!) + function (remember not to spell it as **`SetUpTestSuite`** with a small `u`!) to set up the shared resources and a `static void TearDownTestSuite()` function to tear them down. diff --git a/googletest/include/gtest/gtest-param-test.h b/googletest/include/gtest/gtest-param-test.h index 3f712cfd..a0eecc69 100644 --- a/googletest/include/gtest/gtest-param-test.h +++ b/googletest/include/gtest/gtest-param-test.h @@ -544,11 +544,10 @@ internal::CartesianProductHolder10, and -// return std::string. +// The optional last argument to INSTANTIATE_TEST_SUITE_P allows the user +// to specify a function or functor that generates custom test name suffixes +// based on the test parameters. The function should accept one argument of +// type testing::TestParamInfo, and return std::string. // // testing::PrintToStringParamName is a builtin test suffix generator that // returns the value of testing::PrintToString(GetParam()). @@ -557,21 +556,15 @@ internal::CartesianProductHolder10 \ gtest_##prefix##test_suite_name##_EvalGenerator_() { \ - return GTEST_EXPAND_(GTEST_GET_FIRST_(__VA_ARGS__, DUMMY_PARAM_)); \ + return generator; \ } \ static ::std::string gtest_##prefix##test_suite_name##_EvalGenerateName_( \ const ::testing::TestParamInfo& info) { \ - return GTEST_EXPAND_(GTEST_GET_SECOND_( \ - __VA_ARGS__, \ - ::testing::internal::DefaultParamName, \ - DUMMY_PARAM_))(info); \ + return ::testing::internal::GetParamNameGen( \ + __VA_ARGS__)(info); \ } \ static int gtest_##prefix##test_suite_name##_dummy_ \ GTEST_ATTRIBUTE_UNUSED_ = \ diff --git a/googletest/include/gtest/internal/gtest-param-util.h b/googletest/include/gtest/internal/gtest-param-util.h index 12b1e527..bca72539 100644 --- a/googletest/include/gtest/internal/gtest-param-util.h +++ b/googletest/include/gtest/internal/gtest-param-util.h @@ -376,6 +376,26 @@ std::string DefaultParamName(const TestParamInfo& info) { 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 +ParamNameGenFunctor GetParamNameGen(ParamNameGenFunctor func) { + return func; +} + +template +struct ParamNameGenFunc { + typedef std::string Type(const TestParamInfo&); +}; + +template +typename ParamNameGenFunc::Type *GetParamNameGen() { + return DefaultParamName; +} + // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. // // Stores a parameter value and later creates tests parameterized with that @@ -480,7 +500,7 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase { using ParamType = typename TestSuite::ParamType; // A function that returns an instance of appropriate generator type. typedef ParamGenerator(GeneratorCreationFunc)(); - typedef std::string ParamNameGeneratorFunc(const TestParamInfo&); + typedef typename ParamNameGenFunc::Type ParamNameGeneratorFunc; explicit ParameterizedTestSuiteInfo(const char* name, CodeLocation code_location)