diff options
| author | Edvard Thörnros <edvard.thornros@gmail.com> | 2021-02-19 18:07:21 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-19 18:07:21 +0100 |
| commit | fe41db5dceecb01a0ada18ea2fc369abb1498aa3 (patch) | |
| tree | 539e63178a3a687bc4df92d53712cd9b028bf0e9 /src/lib.rs | |
| parent | f024e88de53c24fd5e5e2fb2d66947dc93262af8 (diff) | |
| parent | 7e330b8d622183696ddf3c7f8140c6510804e0a0 (diff) | |
| download | sylt-fe41db5dceecb01a0ada18ea2fc369abb1498aa3.tar.gz | |
Merge branch 'main' into unusued-variables
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 29 |
1 files changed, 23 insertions, 6 deletions
@@ -771,9 +771,14 @@ mod tests { #[macro_export] macro_rules! assert_errs { ($result:expr, [ $( $kind:pat ),* ]) => { - eprintln!("{} => {:?}", stringify!($result), $result); - assert!(matches!( - $result.unwrap_err().as_slice(), + let errs = if let Err(errs) = $result { + errs + } else { + eprintln!(" Program succeeded when it should've failed"); + unreachable!(); + }; + if !matches!( + errs.as_slice(), &[$($crate::error::Error { kind: $kind, file: _, @@ -781,7 +786,19 @@ mod tests { message: _, }, )*] - )) + ) { + eprintln!("Unexpected errors"); + eprint!(" Got: ["); + for err in errs { + eprint!(" ErrorKind::{:?} ", err.kind); + } + eprint!("]\n Want: ["); + $( + eprint!(" {} ", stringify!($kind)); + )* + eprintln!("]"); + assert!(false); + } }; } @@ -831,8 +848,8 @@ mod tests { for e in errs.iter() { println!("{}", e); } - println!(" {} - FAILED\n", stringify!($fn)); - panic!(); + eprintln!(" {} - failed\n", stringify!($fn)); + unreachable!(); } } }); |
