From 2a9df8afb951592252d5319c646fdd99ec9891c3 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Sun, 28 Jul 2019 16:56:22 +0000 Subject: Fully expand error messages in tests --- test-suite/tests/serde.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'test-suite/tests/serde.rs') diff --git a/test-suite/tests/serde.rs b/test-suite/tests/serde.rs index bf019d4..95b8bc4 100644 --- a/test-suite/tests/serde.rs +++ b/test-suite/tests/serde.rs @@ -44,21 +44,17 @@ macro_rules! equivalent { } macro_rules! error { - ($ty:ty, $toml:expr, $error:expr) => {{ + ($ty:ty, $toml:expr, $msg_parse:expr, $msg_decode:expr) => {{ println!("attempting parsing"); match toml::from_str::<$ty>(&$toml.to_string()) { Ok(_) => panic!("successful"), - Err(e) => { - assert!(e.to_string().contains($error), "bad error: {}", e); - } + Err(e) => assert_eq!(e.to_string(), $msg_parse), } println!("attempting toml decoding"); match $toml.try_into::<$ty>() { Ok(_) => panic!("successful"), - Err(e) => { - assert!(e.to_string().contains($error), "bad error: {}", e); - } + Err(e) => assert_eq!(e.to_string(), $msg_decode), } }}; } @@ -277,6 +273,7 @@ fn type_errors() { Table(map! { bar: Value::String("a".to_string()) }), + "invalid type: string \"a\", expected isize for key `bar`", "invalid type: string \"a\", expected isize for key `bar`" } @@ -293,6 +290,7 @@ fn type_errors() { bar: Value::String("a".to_string()) }) }), + "invalid type: string \"a\", expected isize for key `foo.bar`", "invalid type: string \"a\", expected isize for key `foo.bar`" } } @@ -307,6 +305,7 @@ fn missing_errors() { error! { Foo, Table(map! { }), + "missing field `bar`", "missing field `bar`" } } -- cgit v1.2.3