Add test with match expr

This commit is contained in:
David Tolnay 2020-01-28 11:43:41 -08:00
parent 5e6ebafd8b
commit 5b89426896
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
1 changed files with 13 additions and 0 deletions

View File

@ -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)]