From 65a49a73f0e7c059ad67d768c860bb296383fd56 Mon Sep 17 00:00:00 2001 From: duxiuxing Date: Tue, 17 Jul 2018 15:46:47 +0800 Subject: Fix warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss --- .../gmock/gmock-generated-function-mockers.h | 4 +-- googlemock/include/gmock/gmock-spec-builders.h | 36 +++++++++++----------- .../include/gmock/internal/gmock-internal-utils.h | 2 +- 3 files changed, 21 insertions(+), 21 deletions(-) (limited to 'googlemock') diff --git a/googlemock/include/gmock/gmock-generated-function-mockers.h b/googlemock/include/gmock/gmock-generated-function-mockers.h index 126c48c7..d5417106 100644 --- a/googlemock/include/gmock/gmock-generated-function-mockers.h +++ b/googlemock/include/gmock/gmock-generated-function-mockers.h @@ -352,7 +352,7 @@ class FunctionMocker : public // // class MockClass { // // Overload 1 -// MockSpec gmock_GetName() { … } +// MockSpec gmock_GetName() { ... } // // Overload 2. Declared const so that the compiler will generate an // // error when trying to resolve between this and overload 4 in // // 'gmock_GetName(WithoutMatchers(), nullptr)'. @@ -363,7 +363,7 @@ class FunctionMocker : public // } // // // Overload 3 -// const string& gmock_GetName() const { … } +// const string& gmock_GetName() const { ... } // // Overload 4 // MockSpec gmock_GetName( // const WithoutMatchers&, const Function*) const { diff --git a/googlemock/include/gmock/gmock-spec-builders.h b/googlemock/include/gmock/gmock-spec-builders.h index cf1e7e23..090cff48 100644 --- a/googlemock/include/gmock/gmock-spec-builders.h +++ b/googlemock/include/gmock/gmock-spec-builders.h @@ -1854,22 +1854,22 @@ inline Expectation::Expectation(internal::ExpectationBase& exp) // NOLINT // parameter. This technique may only be used for non-overloaded methods. // // // These are the same: -// ON_CALL(mock, NoArgsMethod()).WillByDefault(…); -// ON_CALL(mock, NoArgsMethod).WillByDefault(…); +// ON_CALL(mock, NoArgsMethod()).WillByDefault(...); +// ON_CALL(mock, NoArgsMethod).WillByDefault(...); // // // As are these: -// ON_CALL(mock, TwoArgsMethod(_, _)).WillByDefault(…); -// ON_CALL(mock, TwoArgsMethod).WillByDefault(…); +// ON_CALL(mock, TwoArgsMethod(_, _)).WillByDefault(...); +// ON_CALL(mock, TwoArgsMethod).WillByDefault(...); // // // Can also specify args if you want, of course: -// ON_CALL(mock, TwoArgsMethod(_, 45)).WillByDefault(…); +// ON_CALL(mock, TwoArgsMethod(_, 45)).WillByDefault(...); // // // Overloads work as long as you specify parameters: -// ON_CALL(mock, OverloadedMethod(_)).WillByDefault(…); -// ON_CALL(mock, OverloadedMethod(_, _)).WillByDefault(…); +// ON_CALL(mock, OverloadedMethod(_)).WillByDefault(...); +// ON_CALL(mock, OverloadedMethod(_, _)).WillByDefault(...); // // // Oops! Which overload did you want? -// ON_CALL(mock, OverloadedMethod).WillByDefault(…); +// ON_CALL(mock, OverloadedMethod).WillByDefault(...); // => ERROR: call to member function 'gmock_OverloadedMethod' is ambiguous // // How this works: The mock class uses two overloads of the gmock_Method @@ -1877,28 +1877,28 @@ inline Expectation::Expectation(internal::ExpectationBase& exp) // NOLINT // In the matcher list form, the macro expands to: // // // This statement: -// ON_CALL(mock, TwoArgsMethod(_, 45))… +// ON_CALL(mock, TwoArgsMethod(_, 45))... // -// // …expands to: -// mock.gmock_TwoArgsMethod(_, 45)(WithoutMatchers(), nullptr)… +// // ...expands to: +// mock.gmock_TwoArgsMethod(_, 45)(WithoutMatchers(), nullptr)... // |-------------v---------------||------------v-------------| // invokes first overload swallowed by operator() // -// // …which is essentially: -// mock.gmock_TwoArgsMethod(_, 45)… +// // ...which is essentially: +// mock.gmock_TwoArgsMethod(_, 45)... // // Whereas the form without a matcher list: // // // This statement: -// ON_CALL(mock, TwoArgsMethod)… +// ON_CALL(mock, TwoArgsMethod)... // -// // …expands to: -// mock.gmock_TwoArgsMethod(WithoutMatchers(), nullptr)… +// // ...expands to: +// mock.gmock_TwoArgsMethod(WithoutMatchers(), nullptr)... // |-----------------------v--------------------------| // invokes second overload // -// // …which is essentially: -// mock.gmock_TwoArgsMethod(_, _)… +// // ...which is essentially: +// mock.gmock_TwoArgsMethod(_, _)... // // The WithoutMatchers() argument is used to disambiguate overloads and to // block the caller from accidentally invoking the second overload directly. The diff --git a/googlemock/include/gmock/internal/gmock-internal-utils.h b/googlemock/include/gmock/internal/gmock-internal-utils.h index 4751788a..c5841aba 100644 --- a/googlemock/include/gmock/internal/gmock-internal-utils.h +++ b/googlemock/include/gmock/internal/gmock-internal-utils.h @@ -348,7 +348,7 @@ GTEST_API_ void Log(LogSeverity severity, const std::string& message, // correct overload. This must not be instantiable, to prevent client code from // accidentally resolving to the overload; for example: // -// ON_CALL(mock, Method({}, nullptr))… +// ON_CALL(mock, Method({}, nullptr))... // class WithoutMatchers { private: -- cgit v1.2.3 From 3530ab9e437b57e9d6778f646d5b88343cae5e02 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Wed, 18 Jul 2018 11:51:14 -0400 Subject: Code sync --- googlemock/test/gmock-matchers_test.cc | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'googlemock') diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc index 87b2ad5c..a4518425 100644 --- a/googlemock/test/gmock-matchers_test.cc +++ b/googlemock/test/gmock-matchers_test.cc @@ -2680,7 +2680,7 @@ TEST(AllOfTest, ExplainsResult) { } // Helper to allow easy testing of AnyOf matchers with num parameters. -void AnyOfMatches(int num, const Matcher& m) { +static void AnyOfMatches(int num, const Matcher& m) { SCOPED_TRACE(Describe(m)); EXPECT_FALSE(m.Matches(0)); for (int i = 1; i <= num; ++i) { @@ -2689,6 +2689,18 @@ void AnyOfMatches(int num, const Matcher& m) { EXPECT_FALSE(m.Matches(num + 1)); } +#if GTEST_LANG_CXX11 +static void AnyOfStringMatches(int num, const Matcher& m) { + SCOPED_TRACE(Describe(m)); + EXPECT_FALSE(m.Matches(std::to_string(0))); + + for (int i = 1; i <= num; ++i) { + EXPECT_TRUE(m.Matches(std::to_string(i))); + } + EXPECT_FALSE(m.Matches(std::to_string(num + 1))); +} +#endif + // Tests that AnyOf(m1, ..., mn) matches any value that matches at // least one of the given matchers. TEST(AnyOfTest, MatchesWhenAnyMatches) { @@ -2746,6 +2758,12 @@ TEST(AnyOfTest, VariadicMatchesWhenAnyMatches) { 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50)); + AnyOfStringMatches( + 50, AnyOf("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", + "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", + "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", + "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", + "43", "44", "45", "46", "47", "48", "49", "50")); } // Tests the variadic version of the ElementsAreMatcher @@ -4570,7 +4588,7 @@ TEST(ResultOfTest, WorksForFunctors) { } // Tests that ResultOf(f, ...) compiles and works as expected when f is a -// functor with more then one operator() defined. ResultOf() must work +// functor with more than one operator() defined. ResultOf() must work // for each defined operator(). struct PolymorphicFunctor { typedef int result_type; @@ -6764,4 +6782,3 @@ TEST(NotTest, WorksOnMoveOnlyType) { } // namespace gmock_matchers_test } // namespace testing - -- cgit v1.2.3 From 0c17888bcfa7a05ae2cb14c1f5e2451ea9745211 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Thu, 19 Jul 2018 12:42:39 -0400 Subject: code sync --- googlemock/include/gmock/gmock-matchers.h | 12 ++++++++---- googlemock/test/gmock-matchers_test.cc | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'googlemock') diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index c94f5826..7fd57870 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -5165,13 +5165,17 @@ std::string DescribeMatcher(const M& matcher, bool negation = false) { // Define variadic matcher versions. They are overloaded in // gmock-generated-matchers.h for the cases supported by pre C++11 compilers. template -internal::AllOfMatcher AllOf(const Args&... matchers) { - return internal::AllOfMatcher(matchers...); +internal::AllOfMatcher::type...> AllOf( + const Args&... matchers) { + return internal::AllOfMatcher::type...>( + matchers...); } template -internal::AnyOfMatcher AnyOf(const Args&... matchers) { - return internal::AnyOfMatcher(matchers...); +internal::AnyOfMatcher::type...> AnyOf( + const Args&... matchers) { + return internal::AnyOfMatcher::type...>( + matchers...); } template diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc index a4518425..f9dfd3c1 100644 --- a/googlemock/test/gmock-matchers_test.cc +++ b/googlemock/test/gmock-matchers_test.cc @@ -2795,6 +2795,7 @@ TEST(ElementsAreTest, HugeMatcherUnordered) { #endif // GTEST_LANG_CXX11 + // Tests that AnyOf(m1, ..., mn) describes itself properly. TEST(AnyOfTest, CanDescribeSelf) { Matcher m; -- cgit v1.2.3 From 2eb43960076417a3dca33ea5ad58e3e9feaee6e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=9C=E4=BF=AE=E6=9D=8F?= Date: Fri, 20 Jul 2018 06:15:13 +0800 Subject: =?UTF-8?q?Replace=20"=E2=80=A6"=20with=20"..."(three=20dots)=20to?= =?UTF-8?q?=20fix=20warning=20C4819=20in=20Visual=20Studio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- googlemock/docs/CookBook.md | 4 ++-- googlemock/include/gmock/gmock-generated-function-mockers.h.pump | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'googlemock') diff --git a/googlemock/docs/CookBook.md b/googlemock/docs/CookBook.md index bd9f026b..8809b0e7 100644 --- a/googlemock/docs/CookBook.md +++ b/googlemock/docs/CookBook.md @@ -2247,7 +2247,7 @@ enum class AccessLevel { kInternal, kPublic }; class Buzz { public: - explicit Buzz(AccessLevel access) { … } + explicit Buzz(AccessLevel access) { ... } ... }; @@ -2320,7 +2320,7 @@ Note that `ByMove()` is essential here - if you drop it, the code won’t compil Quiz time! What do you think will happen if a `Return(ByMove(...))` action is performed more than once (e.g. you write -`….WillRepeatedly(Return(ByMove(...)));`)? Come think of it, after the first +`.WillRepeatedly(Return(ByMove(...)));`)? Come think of it, after the first time the action runs, the source value will be consumed (since it’s a move-only value), so the next time around, there’s no value to move from -- you’ll get a run-time error that `Return(ByMove(...))` can only be run once. diff --git a/googlemock/include/gmock/gmock-generated-function-mockers.h.pump b/googlemock/include/gmock/gmock-generated-function-mockers.h.pump index efcb3e8c..98659226 100644 --- a/googlemock/include/gmock/gmock-generated-function-mockers.h.pump +++ b/googlemock/include/gmock/gmock-generated-function-mockers.h.pump @@ -114,7 +114,7 @@ class FunctionMocker : public // // class MockClass { // // Overload 1 -// MockSpec gmock_GetName() { … } +// MockSpec gmock_GetName() { ... } // // Overload 2. Declared const so that the compiler will generate an // // error when trying to resolve between this and overload 4 in // // 'gmock_GetName(WithoutMatchers(), nullptr)'. @@ -125,7 +125,7 @@ class FunctionMocker : public // } // // // Overload 3 -// const string& gmock_GetName() const { … } +// const string& gmock_GetName() const { ... } // // Overload 4 // MockSpec gmock_GetName( // const WithoutMatchers&, const Function*) const { -- cgit v1.2.3 From a02af2f689426aa9622b06643f53ed27fa6dc8a5 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Fri, 20 Jul 2018 11:28:58 -0400 Subject: code merge --- googlemock/include/gmock/gmock-matchers.h | 14 ++++++++++++++ googlemock/test/gmock-matchers_test.cc | 5 ++++- 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'googlemock') diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index 7fd57870..eb096135 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -4529,6 +4529,20 @@ Property(PropertyType (Class::*property)() const &, property, MatcherCast(matcher))); } + +// Three-argument form for reference-qualified member functions. +template +inline PolymorphicMatcher > +Property(const std::string& property_name, + PropertyType (Class::*property)() const &, + const PropertyMatcher& matcher) { + return MakePolymorphicMatcher( + internal::PropertyMatcher( + property_name, property, + MatcherCast(matcher))); +} #endif // Creates a matcher that matches an object iff the result of applying diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc index f9dfd3c1..9f1a5471 100644 --- a/googlemock/test/gmock-matchers_test.cc +++ b/googlemock/test/gmock-matchers_test.cc @@ -2795,7 +2795,6 @@ TEST(ElementsAreTest, HugeMatcherUnordered) { #endif // GTEST_LANG_CXX11 - // Tests that AnyOf(m1, ..., mn) describes itself properly. TEST(AnyOfTest, CanDescribeSelf) { Matcher m; @@ -4239,13 +4238,17 @@ TEST(PropertyTest, WorksForReferenceToConstProperty) { // ref-qualified. TEST(PropertyTest, WorksForRefQualifiedProperty) { Matcher m = Property(&AClass::s_ref, StartsWith("hi")); + Matcher m_with_name = + Property("s", &AClass::s_ref, StartsWith("hi")); AClass a; a.set_s("hill"); EXPECT_TRUE(m.Matches(a)); + EXPECT_TRUE(m_with_name.Matches(a)); a.set_s("hole"); EXPECT_FALSE(m.Matches(a)); + EXPECT_FALSE(m_with_name.Matches(a)); } #endif -- cgit v1.2.3