Index: testing/gmock/test/gmock-matchers_test.cc |
diff --git a/testing/gmock/test/gmock-matchers_test.cc b/testing/gmock/test/gmock-matchers_test.cc |
index 20b9387f6b093fed66e8630026752e01eb107052..907749d19833528b6010f9180b986f67a4be990c 100644 |
--- a/testing/gmock/test/gmock-matchers_test.cc |
+++ b/testing/gmock/test/gmock-matchers_test.cc |
@@ -121,6 +121,8 @@ using testing::internal::ValidateMatcherDescription; |
using testing::internal::kInvalidInterpolation; |
using testing::internal::kPercentInterpolation; |
using testing::internal::kTupleInterpolation; |
+using testing::internal::linked_ptr; |
+using testing::internal::scoped_ptr; |
using testing::internal::string; |
#ifdef GMOCK_HAS_REGEX |
@@ -150,8 +152,9 @@ class GreaterThanMatcher : public MatcherInterface<int> { |
*os << "is " << -diff << " less than " << rhs_; |
} |
} |
+ |
private: |
- const int rhs_; |
+ int rhs_; |
}; |
Matcher<int> GreaterThan(int n) { |
@@ -333,7 +336,7 @@ class IntValue { |
public: |
// An int can be statically (although not implicitly) cast to a |
// IntValue. |
- explicit IntValue(int value) : value_(value) {} |
+ explicit IntValue(int a_value) : value_(a_value) {} |
int value() const { return value_; } |
private: |
@@ -558,7 +561,7 @@ class Unprintable { |
public: |
Unprintable() : c_('a') {} |
- bool operator==(const Unprintable& rhs) { return true; } |
+ bool operator==(const Unprintable& /* rhs */) { return true; } |
private: |
char c_; |
}; |
@@ -604,7 +607,7 @@ TEST(TypedEqTest, CanDescribeSelf) { |
// "undefined referece". |
template <typename T> |
struct Type { |
- static bool IsTypeOf(const T& v) { return true; } |
+ static bool IsTypeOf(const T& /* v */) { return true; } |
template <typename T2> |
static void IsTypeOf(T2 v); |
@@ -715,6 +718,33 @@ TEST(IsNullTest, MatchesNullPointer) { |
#endif |
} |
+TEST(IsNullTest, LinkedPtr) { |
+ const Matcher<linked_ptr<int> > m = IsNull(); |
+ const linked_ptr<int> null_p; |
+ const linked_ptr<int> non_null_p(new int); |
+ |
+ EXPECT_TRUE(m.Matches(null_p)); |
+ EXPECT_FALSE(m.Matches(non_null_p)); |
+} |
+ |
+TEST(IsNullTest, ReferenceToConstLinkedPtr) { |
+ const Matcher<const linked_ptr<double>&> m = IsNull(); |
+ const linked_ptr<double> null_p; |
+ const linked_ptr<double> non_null_p(new double); |
+ |
+ EXPECT_TRUE(m.Matches(null_p)); |
+ EXPECT_FALSE(m.Matches(non_null_p)); |
+} |
+ |
+TEST(IsNullTest, ReferenceToConstScopedPtr) { |
+ const Matcher<const scoped_ptr<double>&> m = IsNull(); |
+ const scoped_ptr<double> null_p; |
+ const scoped_ptr<double> non_null_p(new double); |
+ |
+ EXPECT_TRUE(m.Matches(null_p)); |
+ EXPECT_FALSE(m.Matches(non_null_p)); |
+} |
+ |
// Tests that IsNull() describes itself properly. |
TEST(IsNullTest, CanDescribeSelf) { |
Matcher<int*> m = IsNull(); |
@@ -736,6 +766,33 @@ TEST(NotNullTest, MatchesNonNullPointer) { |
EXPECT_TRUE(m2.Matches("hi")); |
} |
+TEST(NotNullTest, LinkedPtr) { |
+ const Matcher<linked_ptr<int> > m = NotNull(); |
+ const linked_ptr<int> null_p; |
+ const linked_ptr<int> non_null_p(new int); |
+ |
+ EXPECT_FALSE(m.Matches(null_p)); |
+ EXPECT_TRUE(m.Matches(non_null_p)); |
+} |
+ |
+TEST(NotNullTest, ReferenceToConstLinkedPtr) { |
+ const Matcher<const linked_ptr<double>&> m = NotNull(); |
+ const linked_ptr<double> null_p; |
+ const linked_ptr<double> non_null_p(new double); |
+ |
+ EXPECT_FALSE(m.Matches(null_p)); |
+ EXPECT_TRUE(m.Matches(non_null_p)); |
+} |
+ |
+TEST(NotNullTest, ReferenceToConstScopedPtr) { |
+ const Matcher<const scoped_ptr<double>&> m = NotNull(); |
+ const scoped_ptr<double> null_p; |
+ const scoped_ptr<double> non_null_p(new double); |
+ |
+ EXPECT_FALSE(m.Matches(null_p)); |
+ EXPECT_TRUE(m.Matches(non_null_p)); |
+} |
+ |
// Tests that NotNull() describes itself properly. |
TEST(NotNullTest, CanDescribeSelf) { |
Matcher<int*> m = NotNull(); |
@@ -1805,8 +1862,9 @@ class IsGreaterThan { |
explicit IsGreaterThan(int threshold) : threshold_(threshold) {} |
bool operator()(int n) const { return n > threshold_; } |
+ |
private: |
- const int threshold_; |
+ int threshold_; |
}; |
// For testing Truly(). |
@@ -1903,7 +1961,12 @@ TEST(AllArgsTest, WorksForNonTuple) { |
class AllArgsHelper { |
public: |
+ AllArgsHelper() {} |
+ |
MOCK_METHOD2(Helper, int(char x, int y)); |
+ |
+ private: |
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(AllArgsHelper); |
}; |
TEST(AllArgsTest, WorksInWithClause) { |
@@ -2328,7 +2391,7 @@ TEST(PointeeTest, CanExplainMatchResult) { |
// An uncopyable class. |
class Uncopyable { |
public: |
- explicit Uncopyable(int value) : value_(value) {} |
+ explicit Uncopyable(int a_value) : value_(a_value) {} |
int value() const { return value_; } |
private: |
@@ -2349,11 +2412,17 @@ struct AStruct { |
const double y; // A const field. |
Uncopyable z; // An uncopyable field. |
const char* p; // A pointer field. |
+ |
+ private: |
+ GTEST_DISALLOW_ASSIGN_(AStruct); |
}; |
// A derived struct for testing Field(). |
struct DerivedStruct : public AStruct { |
char ch; |
+ |
+ private: |
+ GTEST_DISALLOW_ASSIGN_(DerivedStruct); |
}; |
// Tests that Field(&Foo::field, ...) works when field is non-const. |
@@ -2887,7 +2956,7 @@ TEST(ResultOfTest, WorksForReferencingCallables) { |
class DivisibleByImpl { |
public: |
- explicit DivisibleByImpl(int divider) : divider_(divider) {} |
+ explicit DivisibleByImpl(int a_divider) : divider_(a_divider) {} |
template <typename T> |
bool Matches(const T& n) const { |
@@ -2902,7 +2971,7 @@ class DivisibleByImpl { |
*os << "is not divisible by " << divider_; |
} |
- void set_divider(int divider) { divider_ = divider; } |
+ void set_divider(int a_divider) { divider_ = a_divider; } |
int divider() const { return divider_; } |
private: |
@@ -2965,7 +3034,7 @@ TEST(ExplainmatcherResultTest, MonomorphicMatcher) { |
class NotCopyable { |
public: |
- explicit NotCopyable(int value) : value_(value) {} |
+ explicit NotCopyable(int a_value) : value_(a_value) {} |
int value() const { return value_; } |