aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386>2013-03-25 16:27:03 +0000
committerzhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386>2013-03-25 16:27:03 +0000
commit1f122a06e6aad4d234123d2d8c1e352029ce0742 (patch)
tree9760e4477a4ca9c8405dab2dbe3d0dd63c266ea5 /test
parent2eab17b76d350dac1b1c85879ec8e1135da615ce (diff)
downloadgoogletest-1f122a06e6aad4d234123d2d8c1e352029ce0742.tar.gz
googletest-1f122a06e6aad4d234123d2d8c1e352029ce0742.tar.bz2
googletest-1f122a06e6aad4d234123d2d8c1e352029ce0742.zip
Adds special support for matching StringPiece. Pulls in gtest r646.
Diffstat (limited to 'test')
-rw-r--r--test/gmock-matchers_test.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/gmock-matchers_test.cc b/test/gmock-matchers_test.cc
index 81460925..3a834a18 100644
--- a/test/gmock-matchers_test.cc
+++ b/test/gmock-matchers_test.cc
@@ -364,6 +364,44 @@ TEST(StringMatcherTest, CanBeImplicitlyConstructedFromString) {
EXPECT_FALSE(m2.Matches("hello"));
}
+#if GTEST_HAS_STRING_PIECE_
+// Tests that a C-string literal can be implicitly converted to a
+// Matcher<StringPiece> or Matcher<const StringPiece&>.
+TEST(StringPieceMatcherTest, CanBeImplicitlyConstructedFromCStringLiteral) {
+ Matcher<StringPiece> m1 = "cats";
+ EXPECT_TRUE(m1.Matches("cats"));
+ EXPECT_FALSE(m1.Matches("dogs"));
+
+ Matcher<const StringPiece&> m2 = "cats";
+ EXPECT_TRUE(m2.Matches("cats"));
+ EXPECT_FALSE(m2.Matches("dogs"));
+}
+
+// Tests that a string object can be implicitly converted to a
+// Matcher<StringPiece> or Matcher<const StringPiece&>.
+TEST(StringPieceMatcherTest, CanBeImplicitlyConstructedFromString) {
+ Matcher<StringPiece> m1 = string("cats");
+ EXPECT_TRUE(m1.Matches("cats"));
+ EXPECT_FALSE(m1.Matches("dogs"));
+
+ Matcher<const StringPiece&> m2 = string("cats");
+ EXPECT_TRUE(m2.Matches("cats"));
+ EXPECT_FALSE(m2.Matches("dogs"));
+}
+
+// Tests that a StringPiece object can be implicitly converted to a
+// Matcher<StringPiece> or Matcher<const StringPiece&>.
+TEST(StringPieceMatcherTest, CanBeImplicitlyConstructedFromStringPiece) {
+ Matcher<StringPiece> m1 = StringPiece("cats");
+ EXPECT_TRUE(m1.Matches("cats"));
+ EXPECT_FALSE(m1.Matches("dogs"));
+
+ Matcher<const StringPiece&> m2 = StringPiece("cats");
+ EXPECT_TRUE(m2.Matches("cats"));
+ EXPECT_FALSE(m2.Matches("dogs"));
+}
+#endif // GTEST_HAS_STRING_PIECE_
+
// Tests that MakeMatcher() constructs a Matcher<T> from a
// MatcherInterface* without requiring the user to explicitly
// write the type.