summaryrefslogtreecommitdiffstats
path: root/googlemock/test
diff options
context:
space:
mode:
authormisterg <misterg@google.com>2019-08-26 18:31:27 (GMT)
committerGennadiy Civil <misterg@google.com>2019-08-26 18:43:56 (GMT)
commit6a3d632f40a1882cb09aeefa767f0fdf1f61c80e (patch)
tree3fd11dcc8ef32305a28117f165d83d4e5873ae5b /googlemock/test
parented2eef654373c17b96bf5a007bb481a6e96ba629 (diff)
downloadgoogletest-6a3d632f40a1882cb09aeefa767f0fdf1f61c80e.zip
googletest-6a3d632f40a1882cb09aeefa767f0fdf1f61c80e.tar.gz
googletest-6a3d632f40a1882cb09aeefa767f0fdf1f61c80e.tar.bz2
Googletest export
Add tuple version of Optional() matches. This allows Optional() to be used in Pointwise matchers. PiperOrigin-RevId: 265501882
Diffstat (limited to 'googlemock/test')
-rw-r--r--googlemock/test/gmock-matchers_test.cc35
1 files changed, 1 insertions, 34 deletions
diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc
index f5e25e0..a61d040 100644
--- a/googlemock/test/gmock-matchers_test.cc
+++ b/googlemock/test/gmock-matchers_test.cc
@@ -6387,7 +6387,7 @@ class SampleOptional {
explicit SampleOptional(T value)
: value_(std::move(value)), has_value_(true) {}
SampleOptional() : value_(), has_value_(false) {}
- explicit operator bool() const { return has_value_; }
+ operator bool() const { return has_value_; }
const T& operator*() const { return value_; }
private:
@@ -6427,39 +6427,6 @@ TEST(OptionalTest, WorksWithMoveOnly) {
EXPECT_TRUE(m.Matches(SampleOptional<std::unique_ptr<int>>(nullptr)));
}
-TEST(OptionalTest, TupleDescribesSelf) {
- const Matcher<std::tuple<SampleOptional<int>, int>> m = Optional(Eq());
- EXPECT_EQ("are optionals where the values are an equal pair", Describe(m));
-}
-
-TEST(OptionalTest, TupleExplainsSelf) {
- const Matcher<std::tuple<SampleOptional<int>, int>> m = Optional(Eq());
- EXPECT_EQ("which match",
- Explain(m, std::make_tuple(SampleOptional<int>(1), 1)));
- EXPECT_EQ("whose values don't match",
- Explain(m, std::make_tuple(SampleOptional<int>(1), 2)));
-}
-
-TEST(OptionalTest, TupleMatchesNonEmpty) {
- const Matcher<std::tuple<SampleOptional<int>, int>> m1 = Optional(Eq());
- const Matcher<std::tuple<SampleOptional<int>, int>> m2 = Optional(Lt());
- EXPECT_TRUE(m1.Matches(std::make_tuple(SampleOptional<int>(1), 1)));
- EXPECT_FALSE(m1.Matches(std::make_tuple(SampleOptional<int>(1), 2)));
- EXPECT_FALSE(m2.Matches(std::make_tuple(SampleOptional<int>(1), 1)));
- EXPECT_TRUE(m2.Matches(std::make_tuple(SampleOptional<int>(1), 2)));
-}
-
-TEST(OptionalTest, TupleDoesNotMatchNullopt) {
- const Matcher<std::tuple<SampleOptional<int>, int>> m1 = Optional(Eq());
- EXPECT_FALSE(m1.Matches(std::make_tuple(SampleOptional<int>(), 1)));
-}
-
-TEST(OptionalTest, TupleWorksInPointwise) {
- std::vector<SampleOptional<int>> v = {
- SampleOptional<int>(1), SampleOptional<int>(2), SampleOptional<int>(3)};
- EXPECT_THAT(v, Pointwise(Optional(Eq()), {1, 2, 3}));
-}
-
class SampleVariantIntString {
public:
SampleVariantIntString(int i) : i_(i), has_int_(true) {}