diff options
author | zhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386> | 2013-03-01 00:20:30 +0000 |
---|---|---|
committer | zhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386> | 2013-03-01 00:20:30 +0000 |
commit | 320814aca02dfb6b5f116bc5de1785a478cc6d42 (patch) | |
tree | 740e33c7045025d19ed9783bed79239d41144d81 /test | |
parent | edd4ab4945aeacdf9bd5ec3ac1654b940ca72532 (diff) | |
download | googletest-320814aca02dfb6b5f116bc5de1785a478cc6d42.tar.gz googletest-320814aca02dfb6b5f116bc5de1785a478cc6d42.tar.bz2 googletest-320814aca02dfb6b5f116bc5de1785a478cc6d42.zip |
Implements matcher IsEmpty(); also pulls in gtest r643.
Diffstat (limited to 'test')
-rw-r--r-- | test/gmock-matchers_test.cc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/gmock-matchers_test.cc b/test/gmock-matchers_test.cc index de3f8d73..e75b06e0 100644 --- a/test/gmock-matchers_test.cc +++ b/test/gmock-matchers_test.cc @@ -34,6 +34,7 @@ // This file tests some commonly used argument matchers. #include "gmock/gmock-matchers.h" +#include "gmock/gmock-more-matchers.h" #include <string.h> #include <functional> @@ -88,6 +89,7 @@ using testing::FloatEq; using testing::Ge; using testing::Gt; using testing::HasSubstr; +using testing::IsEmpty; using testing::IsNull; using testing::Key; using testing::Le; @@ -3603,6 +3605,38 @@ TEST(ByRefTest, AllowsNotCopyableValueInMatchers) { EXPECT_TRUE(m.Matches(n2)); } +TEST(IsEmptyTest, ImplementsIsEmpty) { + vector<int> container; + EXPECT_THAT(container, IsEmpty()); + container.push_back(0); + EXPECT_THAT(container, Not(IsEmpty())); + container.push_back(1); + EXPECT_THAT(container, Not(IsEmpty())); +} + +TEST(IsEmptyTest, WorksWithString) { + string text; + EXPECT_THAT(text, IsEmpty()); + text = "foo"; + EXPECT_THAT(text, Not(IsEmpty())); + text = string("\0", 1); + EXPECT_THAT(text, Not(IsEmpty())); +} + +TEST(IsEmptyTest, CanDescribeSelf) { + Matcher<vector<int> > m = IsEmpty(); + EXPECT_EQ("is empty", Describe(m)); + EXPECT_EQ("isn't empty", DescribeNegation(m)); +} + +TEST(IsEmptyTest, ExplainsResult) { + Matcher<vector<int> > m = IsEmpty(); + vector<int> container; + EXPECT_EQ("", Explain(m, container)); + container.push_back(0); + EXPECT_EQ("whose size is 1", Explain(m, container)); +} + #if GTEST_HAS_TYPED_TEST // Tests ContainerEq with different container types, and // different element types. |