Skip to content

Commit efc2fc1

Browse files
bjacotgcopybara-github
authored andcommitted
Add impl Matcher<&()> for ()
PiperOrigin-RevId: 684462112
1 parent 5f4ab13 commit efc2fc1

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

googletest/src/matchers/tuple_matcher.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ pub mod internal {
4444
}
4545
}
4646

47+
impl Matcher<&()> for () {
48+
fn matches(&self, _: &()) -> MatcherResult {
49+
MatcherResult::Match
50+
}
51+
52+
fn describe(&self, matcher_result: MatcherResult) -> Description {
53+
<Self as Matcher<()>>::describe(self, matcher_result)
54+
}
55+
}
56+
4757
/// Generates a tuple matcher for tuples of a specific length.
4858
///
4959
/// **For internal use only. API stablility is not guaranteed!**

googletest/tests/tuple_matcher_test.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ fn empty_matcher_matches_empty_tuple() -> Result<()> {
2121
verify_that!((), ())
2222
}
2323

24+
#[test]
25+
fn empty_matcher_matches_empty_tuple_reference() -> Result<()> {
26+
let a_ok: std::result::Result<(), String> = Ok(()); // Non copy
27+
verify_that!(a_ok, ok(()))
28+
}
29+
2430
#[test]
2531
fn singleton_matcher_matches_matching_singleton_tuple() -> Result<()> {
2632
verify_that!((123,), (eq(123),))

0 commit comments

Comments
 (0)