Skip to content

Commit 469f49b

Browse files
Merge pull request #181 from google:better-and-example
PiperOrigin-RevId: 528725659
2 parents 931d550 + 12e588f commit 469f49b

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

googletest/src/matchers/conjunction_matcher.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,22 @@ pub trait AndMatcherExt<T: Debug>: Matcher<ActualT = T> {
2222
/// Constructs a matcher that matches both `self` and `right`.
2323
///
2424
/// ```
25-
/// # use googletest::{field, matchers::{eq, AndMatcherExt}, verify_that, Result};
26-
/// # #[derive(Debug)]
27-
/// # struct Struct { a: u32, b: u32 };
25+
/// # use googletest::{matchers::{ends_with, starts_with, AndMatcherExt}, verify_that, Result};
2826
/// # fn should_pass() -> Result<()> {
29-
/// verify_that!(Struct { a: 1, b: 2 }, field!(Struct.a, eq(1)).and(field!(Struct.b, eq(2))))?;
27+
/// verify_that!("A string", starts_with("A").and(ends_with("string")))?; // Passes
28+
/// # Ok(())
29+
/// # }
30+
/// # fn should_fail_1() -> Result<()> {
31+
/// verify_that!("A string", starts_with("Another").and(ends_with("string")))?; // Fails
32+
/// # Ok(())
33+
/// # }
34+
/// # fn should_fail_2() -> Result<()> {
35+
/// verify_that!("A string", starts_with("A").and(ends_with("non-string")))?; // Fails
3036
/// # Ok(())
3137
/// # }
3238
/// # should_pass().unwrap();
39+
/// # should_fail_1().unwrap_err();
40+
/// # should_fail_2().unwrap_err();
3341
/// ```
3442
// TODO(b/264518763): Replace the return type with impl Matcher and reduce
3543
// visibility of ConjunctionMatcher once impl in return position in trait

0 commit comments

Comments
 (0)