diff options
author | Gennadiy Civil <gennadiycivil@users.noreply.github.com> | 2018-08-27 13:25:45 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-27 13:25:45 -0400 |
commit | ebb2fca51a2b868132992d273bb97696bff969b3 (patch) | |
tree | a5825772e31b5b67c484da238f5935664b4864c4 /googlemock/test/gmock-matchers_test.cc | |
parent | b19292e6b64263992cd049154015a6ef359473ef (diff) | |
parent | 641e7a3752d451d3ea246d1dd1528f6315b87fcf (diff) | |
download | googletest-ebb2fca51a2b868132992d273bb97696bff969b3.tar.gz googletest-ebb2fca51a2b868132992d273bb97696bff969b3.tar.bz2 googletest-ebb2fca51a2b868132992d273bb97696bff969b3.zip |
Merge branch 'master' into fix-1764_CMake-errors-in-googlemock
Diffstat (limited to 'googlemock/test/gmock-matchers_test.cc')
-rw-r--r-- | googlemock/test/gmock-matchers_test.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc index d08f08f7..4697f0bf 100644 --- a/googlemock/test/gmock-matchers_test.cc +++ b/googlemock/test/gmock-matchers_test.cc @@ -4597,6 +4597,7 @@ struct PolymorphicFunctor { typedef int result_type; int operator()(int n) { return n; } int operator()(const char* s) { return static_cast<int>(strlen(s)); } + std::string operator()(int *p) { return p ? "good ptr" : "null"; } }; TEST(ResultOfTest, WorksForPolymorphicFunctors) { @@ -4611,6 +4612,23 @@ TEST(ResultOfTest, WorksForPolymorphicFunctors) { EXPECT_FALSE(matcher_string.Matches("shrt")); } +#if GTEST_LANG_CXX11 +TEST(ResultOfTest, WorksForPolymorphicFunctorsIgnoringResultType) { + Matcher<int*> matcher = ResultOf(PolymorphicFunctor(), "good ptr"); + + int n = 0; + EXPECT_TRUE(matcher.Matches(&n)); + EXPECT_FALSE(matcher.Matches(nullptr)); +} + +TEST(ResultOfTest, WorksForLambdas) { + Matcher<int> matcher = + ResultOf([](int str_len) { return std::string(str_len, 'x'); }, "xxx"); + EXPECT_TRUE(matcher.Matches(3)); + EXPECT_FALSE(matcher.Matches(1)); +} +#endif + const int* ReferencingFunction(const int& n) { return &n; } struct ReferencingFunctor { |