aboutsummaryrefslogtreecommitdiffstats
path: root/googlemock/test/gmock-matchers_test.cc
diff options
context:
space:
mode:
authorScott Slack-Smith <deenderah@gmail.com>2017-11-24 16:00:56 +0000
committerScott Slack-Smith <deenderah@gmail.com>2017-11-24 16:00:56 +0000
commit6c093a2391eb66a42bd4146443265eddad06be0c (patch)
treeb61e233a023b5c5a43c31520fd6b84f5a4b37788 /googlemock/test/gmock-matchers_test.cc
parentc958e26fd02d43a916ff297c89eee22166fe7be7 (diff)
parentd175c8bf823e709d570772b038757fadf63bc632 (diff)
downloadgoogletest-6c093a2391eb66a42bd4146443265eddad06be0c.tar.gz
googletest-6c093a2391eb66a42bd4146443265eddad06be0c.tar.bz2
googletest-6c093a2391eb66a42bd4146443265eddad06be0c.zip
Merge branch 'master' of https://github.com/google/googletest
Diffstat (limited to 'googlemock/test/gmock-matchers_test.cc')
-rw-r--r--googlemock/test/gmock-matchers_test.cc32
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);
}
};