Add test with match expr
This commit is contained in:
parent
5e6ebafd8b
commit
5b89426896
|
@ -121,6 +121,19 @@ fn test_nested() {
|
|||
assert("!bool = false", Error(true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_match() {
|
||||
#[derive(Error, Debug)]
|
||||
#[error("{}: {0}", match .1 {
|
||||
Some(n) => format!("error occurred with {}", n),
|
||||
None => format!("there was an empty error"),
|
||||
})]
|
||||
struct Error(String, Option<usize>);
|
||||
|
||||
assert("error occurred with 1: ...", Error("...".to_owned(), Some(1)));
|
||||
assert("there was an empty error: ...", Error("...".to_owned(), None));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_void() {
|
||||
#[derive(Error, Debug)]
|
||||
|
|
Loading…
Reference in New Issue