@@ -17,6 +17,17 @@ use crate::{
17
17
matcher:: { Matcher , MatcherBase , MatcherResult } ,
18
18
} ;
19
19
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
+
20
31
/// Match a bool value or bool reference.
21
32
#[ derive( MatcherBase ) ]
22
33
pub struct BoolMatcher {
@@ -55,17 +66,10 @@ impl<'a> Matcher<&'a bool> for BoolMatcher {
55
66
}
56
67
}
57
68
58
- pub fn is_true ( ) -> BoolMatcher {
59
- BoolMatcher { expected : true }
60
- }
61
-
62
- pub fn is_false ( ) -> BoolMatcher {
63
- BoolMatcher { expected : false }
64
- }
65
-
66
69
#[ cfg( test) ]
67
70
mod tests {
68
71
use crate :: prelude:: * ;
72
+ use super :: * ;
69
73
70
74
#[ test]
71
75
fn match_value ( ) -> Result < ( ) > {
@@ -85,4 +89,12 @@ mod tests {
85
89
verify_that ! ( & f, is_false( ) ) ?;
86
90
verify_that ! ( & f, not( is_true( ) ) )
87
91
}
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
+ }
88
100
}
0 commit comments