diff --git a/tests/test_display.rs b/tests/test_display.rs index 7d9ac59..d64b8c2 100644 --- a/tests/test_display.rs +++ b/tests/test_display.rs @@ -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); + + 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)]