summaryrefslogtreecommitdiffstats
path: root/googlemock/test/gmock-generated-matchers_test.cc
diff options
context:
space:
mode:
authorGennadiy Civil <misterg@google.com>2018-04-16 15:18:49 (GMT)
committerGennadiy Civil <misterg@google.com>2018-04-16 15:18:49 (GMT)
commitbd2a1aed03c8319f43ee01ed675d2a2365aac7c5 (patch)
tree65cc9dd810d86f1322a3d1f60bb9bb15a6104e2e /googlemock/test/gmock-generated-matchers_test.cc
parent1f605414cc4137f0ad0cde4d0c7366ff2dfac590 (diff)
downloadgoogletest-bd2a1aed03c8319f43ee01ed675d2a2365aac7c5.zip
googletest-bd2a1aed03c8319f43ee01ed675d2a2365aac7c5.tar.gz
googletest-bd2a1aed03c8319f43ee01ed675d2a2365aac7c5.tar.bz2
merging gmock generated matchers
Diffstat (limited to 'googlemock/test/gmock-generated-matchers_test.cc')
-rw-r--r--googlemock/test/gmock-generated-matchers_test.cc51
1 files changed, 47 insertions, 4 deletions
diff --git a/googlemock/test/gmock-generated-matchers_test.cc b/googlemock/test/gmock-generated-matchers_test.cc
index 6cba726..f24d7c8 100644
--- a/googlemock/test/gmock-generated-matchers_test.cc
+++ b/googlemock/test/gmock-generated-matchers_test.cc
@@ -35,6 +35,7 @@
#include <list>
#include <map>
+#include <memory>
#include <set>
#include <sstream>
#include <string>
@@ -57,6 +58,8 @@ using testing::get;
using testing::make_tuple;
using testing::tuple;
using testing::_;
+using testing::AllOf;
+using testing::AnyOf;
using testing::Args;
using testing::Contains;
using testing::ElementsAre;
@@ -120,7 +123,7 @@ TEST(ArgsTest, AcceptsOneTemplateArg) {
}
TEST(ArgsTest, AcceptsTwoTemplateArgs) {
- const tuple<short, int, long> t(static_cast<short>(4), 5, 6L); // NOLINT
+ const tuple<short, int, long> t(4, 5, 6L); // NOLINT
EXPECT_THAT(t, (Args<0, 1>(Lt())));
EXPECT_THAT(t, (Args<1, 2>(Lt())));
@@ -128,13 +131,13 @@ TEST(ArgsTest, AcceptsTwoTemplateArgs) {
}
TEST(ArgsTest, AcceptsRepeatedTemplateArgs) {
- const tuple<short, int, long> t(static_cast<short>(4), 5, 6L); // NOLINT
+ const tuple<short, int, long> t(4, 5, 6L); // NOLINT
EXPECT_THAT(t, (Args<0, 0>(Eq())));
EXPECT_THAT(t, Not(Args<1, 1>(Ne())));
}
TEST(ArgsTest, AcceptsDecreasingTemplateArgs) {
- const tuple<short, int, long> t(static_cast<short>(4), 5, 6L); // NOLINT
+ const tuple<short, int, long> t(4, 5, 6L); // NOLINT
EXPECT_THAT(t, (Args<2, 0>(Gt())));
EXPECT_THAT(t, Not(Args<2, 1>(Lt())));
}
@@ -159,7 +162,7 @@ TEST(ArgsTest, AcceptsMoreTemplateArgsThanArityOfOriginalTuple) {
}
TEST(ArgsTest, CanBeNested) {
- const tuple<short, int, long, int> t(static_cast<short>(4), 5, 6L, 6); // NOLINT
+ const tuple<short, int, long, int> t(4, 5, 6L, 6); // NOLINT
EXPECT_THAT(t, (Args<1, 2, 3>(Args<1, 2>(Eq()))));
EXPECT_THAT(t, (Args<0, 1, 3>(Args<0, 2>(Lt()))));
}
@@ -1283,4 +1286,44 @@ TEST(AnyOfTest, DoesNotCallAnyOfUnqualified) {
# pragma warning(pop)
#endif
+#if GTEST_LANG_CXX11
+
+TEST(AllOfTest, WorksOnMoveOnlyType) {
+ std::unique_ptr<int> p(new int(3));
+ EXPECT_THAT(p, AllOf(Pointee(Eq(3)), Pointee(Gt(0)), Pointee(Lt(5))));
+ EXPECT_THAT(p, Not(AllOf(Pointee(Eq(3)), Pointee(Gt(0)), Pointee(Lt(3)))));
+}
+
+TEST(AnyOfTest, WorksOnMoveOnlyType) {
+ std::unique_ptr<int> p(new int(3));
+ EXPECT_THAT(p, AnyOf(Pointee(Eq(5)), Pointee(Lt(0)), Pointee(Lt(5))));
+ EXPECT_THAT(p, Not(AnyOf(Pointee(Eq(5)), Pointee(Lt(0)), Pointee(Gt(5)))));
+}
+
+MATCHER(IsNotNull, "") {
+ return arg != nullptr;
+}
+
+// Verifies that a matcher defined using MATCHER() can work on
+// move-only types.
+TEST(MatcherMacroTest, WorksOnMoveOnlyType) {
+ std::unique_ptr<int> p(new int(3));
+ EXPECT_THAT(p, IsNotNull());
+ EXPECT_THAT(std::unique_ptr<int>(), Not(IsNotNull()));
+}
+
+MATCHER_P(UniquePointee, pointee, "") {
+ return *arg == pointee;
+}
+
+// Verifies that a matcher defined using MATCHER_P*() can work on
+// move-only types.
+TEST(MatcherPMacroTest, WorksOnMoveOnlyType) {
+ std::unique_ptr<int> p(new int(3));
+ EXPECT_THAT(p, UniquePointee(3));
+ EXPECT_THAT(p, Not(UniquePointee(2)));
+}
+
+#endif // GTEST_LASNG_CXX11
+
} // namespace