Add support for named value-parameterized tests.

This commit is contained in:
kosak
2015-07-24 19:46:18 +00:00
parent 41b5b28d48
commit 794ef030eb
6 changed files with 351 additions and 18 deletions

View File

@@ -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<std::string>& info) {
return info.param;
}
class ParamTest : public testing::TestWithParam<std::string> {
};
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