Googletest export
Introduce a new `Address` matcher to gmock. PiperOrigin-RevId: 346344591
This commit is contained in:
@@ -3787,6 +3787,46 @@ TEST(PointerTest, SmartPointerToConst) {
|
||||
EXPECT_FALSE(m.Matches(p));
|
||||
}
|
||||
|
||||
TEST(AddressTest, NonConst) {
|
||||
int n = 1;
|
||||
const Matcher<int> m = Address(Eq(&n));
|
||||
|
||||
EXPECT_TRUE(m.Matches(n));
|
||||
|
||||
int other = 5;
|
||||
|
||||
EXPECT_FALSE(m.Matches(other));
|
||||
|
||||
int& n_ref = n;
|
||||
|
||||
EXPECT_TRUE(m.Matches(n_ref));
|
||||
}
|
||||
|
||||
TEST(AddressTest, Const) {
|
||||
const int n = 1;
|
||||
const Matcher<int> m = Address(Eq(&n));
|
||||
|
||||
EXPECT_TRUE(m.Matches(n));
|
||||
|
||||
int other = 5;
|
||||
|
||||
EXPECT_FALSE(m.Matches(other));
|
||||
}
|
||||
|
||||
TEST(AddressTest, MatcherDoesntCopy) {
|
||||
std::unique_ptr<int> n(new int(1));
|
||||
const Matcher<std::unique_ptr<int>> m = Address(Eq(&n));
|
||||
|
||||
EXPECT_TRUE(m.Matches(n));
|
||||
}
|
||||
|
||||
TEST(AddressTest, Describe) {
|
||||
Matcher<int> matcher = Address(_);
|
||||
EXPECT_EQ("has address that is anything", Describe(matcher));
|
||||
EXPECT_EQ("does not have address that is anything",
|
||||
DescribeNegation(matcher));
|
||||
}
|
||||
|
||||
MATCHER_P(FieldIIs, inner_matcher, "") {
|
||||
return ExplainMatchResult(inner_matcher, arg.i, result_listener);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user