diff options
author | kosak <kosak@google.com> | 2015-07-24 19:46:18 +0000 |
---|---|---|
committer | kosak <kosak@google.com> | 2015-07-24 19:46:18 +0000 |
commit | 794ef030ebad671b699abdfd8e0474f93045be91 (patch) | |
tree | 4034db2b543b36945b46702b0158168ef367d622 /include/gtest/gtest-param-test.h.pump | |
parent | 41b5b28d4858530a94078a5204c9d393f520159d (diff) | |
download | googletest-794ef030ebad671b699abdfd8e0474f93045be91.tar.gz googletest-794ef030ebad671b699abdfd8e0474f93045be91.tar.bz2 googletest-794ef030ebad671b699abdfd8e0474f93045be91.zip |
Add support for named value-parameterized tests.
Diffstat (limited to 'include/gtest/gtest-param-test.h.pump')
-rw-r--r-- | include/gtest/gtest-param-test.h.pump | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/include/gtest/gtest-param-test.h.pump b/include/gtest/gtest-param-test.h.pump index 45896502..3078d6d2 100644 --- a/include/gtest/gtest-param-test.h.pump +++ b/include/gtest/gtest-param-test.h.pump @@ -472,9 +472,26 @@ internal::CartesianProductHolder$i<$for j, [[Generator$j]]> Combine( GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::AddToRegistry(); \ void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() -# define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator) \ +// The optional last argument to INSTANTIATE_TEST_CASE_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<class ParamType>, and return std::string. +// +// testing::PrintToStringParamName is a builtin test suffix generator that +// returns the value of testing::PrintToString(GetParam()). +// +// Note: test names must be non-empty, unique, and may only contain ASCII +// alphanumeric characters or underscore. Because PrintToString adds quotes +// to std::string and C strings, it won't work for these types. + +# define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator, ...) \ ::testing::internal::ParamGenerator<test_case_name::ParamType> \ gtest_##prefix##test_case_name##_EvalGenerator_() { return generator; } \ + ::std::string gtest_##prefix##test_case_name##_EvalGenerateName_( \ + const ::testing::TestParamInfo<test_case_name::ParamType>& info) { \ + return ::testing::internal::GetParamNameGen<test_case_name::ParamType> \ + (__VA_ARGS__)(info); \ + } \ int gtest_##prefix##test_case_name##_dummy_ GTEST_ATTRIBUTE_UNUSED_ = \ ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \ GetTestCasePatternHolder<test_case_name>(\ @@ -483,6 +500,7 @@ internal::CartesianProductHolder$i<$for j, [[Generator$j]]> Combine( __FILE__, __LINE__))->AddTestCaseInstantiation(\ #prefix, \ >est_##prefix##test_case_name##_EvalGenerator_, \ + >est_##prefix##test_case_name##_EvalGenerateName_, \ __FILE__, __LINE__) } // namespace testing |