File tree Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ Cargo.lock
2
+ target /
Original file line number Diff line number Diff line change
1
+ [package ]
2
+ name = " testutils"
3
+ version = " 0.1.0"
4
+ authors = [
" Ian Chamberlain <[email protected] >" ]
5
+ edition = " 2018"
6
+
7
+ [dependencies ]
8
+ predicates = " 1.0.2"
9
+ predicates-tree = " 1.0.0"
Original file line number Diff line number Diff line change
1
+ /// Simple macro to panic with a prettier error message
2
+ /// # Examples
3
+ /// ```
4
+ /// use predicates::prelude::*;
5
+ /// use testutils::assert_that;
6
+ ///
7
+ /// assert_that!(
8
+ /// "Hello World",
9
+ /// predicates::str::similar("Hello World"),
10
+ /// );
11
+ /// assert_that!(
12
+ /// "Hello world",
13
+ /// predicates::str::diff("Goodbye world"),
14
+ /// );
15
+ /// ```
16
+ #[ macro_export]
17
+ macro_rules! assert_that {
18
+ ( $item: expr, $pred: expr $( , ) ?) => { {
19
+ use :: predicates:: prelude:: * ;
20
+ use :: predicates_tree:: CaseTreeExt ;
21
+
22
+ if let Some ( case) = $pred. find_case( false , $item) {
23
+ panic!( "{}" , case. tree( ) ) ;
24
+ } ;
25
+ } } ;
26
+ }
You can’t perform that action at this time.
0 commit comments