diff options
author | Josh Bodily <joshbodily@gmail.com> | 2017-12-12 10:36:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-12 10:36:37 -0700 |
commit | 3e2cb75446e0f56f226f0fb259e032bb4d014002 (patch) | |
tree | 4d945ff84ee3affb3187acb1fbb8ba9d300718d8 /googlemock/test/gmock-matchers_test.cc | |
parent | cf85f56b2159d7c964dacb3e311163a6f9520688 (diff) | |
parent | 0fe96607d85cf3a25ac40da369db62bbee2939a5 (diff) | |
download | googletest-3e2cb75446e0f56f226f0fb259e032bb4d014002.tar.gz googletest-3e2cb75446e0f56f226f0fb259e032bb4d014002.tar.bz2 googletest-3e2cb75446e0f56f226f0fb259e032bb4d014002.zip |
Merge branch 'master' into josh/fix_scoped_class2
Diffstat (limited to 'googlemock/test/gmock-matchers_test.cc')
-rw-r--r-- | googlemock/test/gmock-matchers_test.cc | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc index f5ab7c81..4beaec4c 100644 --- a/googlemock/test/gmock-matchers_test.cc +++ b/googlemock/test/gmock-matchers_test.cc @@ -58,6 +58,11 @@ # include <forward_list> // NOLINT #endif +// Disable MSVC2015 warning for std::pair: "decorated name length exceeded, name was truncated". +#if defined(_MSC_VER) && (_MSC_VER == 1900) +# pragma warning(disable:4503) +#endif + namespace testing { namespace internal { @@ -3588,10 +3593,15 @@ class AClass { // A getter that returns a reference to const. const std::string& s() const { return s_; } +#if GTEST_LANG_CXX11 + const std::string& s_ref() const & { return s_; } +#endif + void set_s(const std::string& new_s) { s_ = new_s; } // A getter that returns a reference to non-const. double& x() const { return x_; } + private: int n_; std::string s_; @@ -3635,6 +3645,21 @@ TEST(PropertyTest, WorksForReferenceToConstProperty) { EXPECT_FALSE(m.Matches(a)); } +#if GTEST_LANG_CXX11 +// Tests that Property(&Foo::property, ...) works when property() is +// ref-qualified. +TEST(PropertyTest, WorksForRefQualifiedProperty) { + Matcher<const AClass&> m = Property(&AClass::s_ref, StartsWith("hi")); + + AClass a; + a.set_s("hill"); + EXPECT_TRUE(m.Matches(a)); + + a.set_s("hole"); + EXPECT_FALSE(m.Matches(a)); +} +#endif + // Tests that Property(&Foo::property, ...) works when property() // returns a reference to non-const. TEST(PropertyTest, WorksForReferenceToNonConstProperty) { @@ -3911,8 +3936,11 @@ TEST(ResultOfTest, WorksForFunctionReferences) { // Tests that ResultOf(f, ...) compiles and works as expected when f is a // function object. -struct Functor : public ::std::unary_function<int, std::string> { - result_type operator()(argument_type input) const { +struct Functor { + typedef std::string result_type; + typedef int argument_type; + + std::string operator()(int input) const { return IntToStringFunction(input); } }; |