Skip to content

Commit 4901d42

Browse files
committed
Reorder functions and adds more documents and tests.
1 parent 8dfc566 commit 4901d42

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

googletest/src/matchers/bool_matcher.rs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ use crate::{
1717
matcher::{Matcher, MatcherBase, MatcherResult},
1818
};
1919

20+
/// Matcher that matches boolean value `true`.
21+
pub fn is_true() -> BoolMatcher {
22+
BoolMatcher { expected: true }
23+
}
24+
25+
/// Matches boolean value `false`.
26+
pub fn is_false() -> BoolMatcher {
27+
BoolMatcher { expected: false }
28+
}
29+
30+
2031
/// Match a bool value or bool reference.
2132
#[derive(MatcherBase)]
2233
pub struct BoolMatcher {
@@ -55,17 +66,10 @@ impl<'a> Matcher<&'a bool> for BoolMatcher {
5566
}
5667
}
5768

58-
pub fn is_true() -> BoolMatcher {
59-
BoolMatcher { expected: true }
60-
}
61-
62-
pub fn is_false() -> BoolMatcher {
63-
BoolMatcher { expected: false }
64-
}
65-
6669
#[cfg(test)]
6770
mod tests {
6871
use crate::prelude::*;
72+
use super::*;
6973

7074
#[test]
7175
fn match_value() -> Result<()> {
@@ -85,4 +89,12 @@ mod tests {
8589
verify_that!(&f, is_false())?;
8690
verify_that!(&f, not(is_true()))
8791
}
92+
93+
#[test]
94+
fn describe() {
95+
assert_eq!(is_true().describe(MatcherResult::Match).to_string(), "is true");
96+
assert_eq!(is_true().describe(MatcherResult::NoMatch).to_string(), "is false");
97+
assert_eq!(is_false().describe(MatcherResult::Match).to_string(), "is false");
98+
assert_eq!(is_false().describe(MatcherResult::NoMatch).to_string(), "is true");
99+
}
88100
}

0 commit comments

Comments
 (0)