From 794ef030ebad671b699abdfd8e0474f93045be91 Mon Sep 17 00:00:00 2001 From: kosak Date: Fri, 24 Jul 2015 19:46:18 +0000 Subject: Add support for named value-parameterized tests. --- test/gtest_output_test_.cc | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test/gtest_output_test_.cc') diff --git a/test/gtest_output_test_.cc b/test/gtest_output_test_.cc index a619459c..1070a9f2 100644 --- a/test/gtest_output_test_.cc +++ b/test/gtest_output_test_.cc @@ -755,6 +755,32 @@ TEST(ExpectFatalFailureTest, FailsWhenStatementThrows) { #endif // GTEST_HAS_EXCEPTIONS +// This #ifdef block tests the output of value-parameterized tests. + +#if GTEST_HAS_PARAM_TEST + +std::string ParamNameFunc(const testing::TestParamInfo& info) { + return info.param; +} + +class ParamTest : public testing::TestWithParam { +}; + +TEST_P(ParamTest, Success) { + EXPECT_EQ("a", GetParam()); +} + +TEST_P(ParamTest, Failure) { + EXPECT_EQ("b", GetParam()) << "Expected failure"; +} + +INSTANTIATE_TEST_CASE_P(PrintingStrings, + ParamTest, + testing::Values(std::string("a")), + ParamNameFunc); + +#endif // GTEST_HAS_PARAM_TEST + // This #ifdef block tests the output of typed tests. #if GTEST_HAS_TYPED_TEST -- cgit v1.2.3