diff options
Diffstat (limited to 'test-suite/tests/backcompat.rs')
-rw-r--r-- | test-suite/tests/backcompat.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/test-suite/tests/backcompat.rs b/test-suite/tests/backcompat.rs index 53cda69..45198f0 100644 --- a/test-suite/tests/backcompat.rs +++ b/test-suite/tests/backcompat.rs @@ -3,13 +3,22 @@ extern crate toml; use serde::de::Deserialize; +macro_rules! bad { + ($toml:expr, $msg:expr) => { + match $toml.parse::<toml::Value>() { + Ok(s) => panic!("parsed to: {:#?}", s), + Err(e) => assert_eq!(e.to_string(), $msg), + } + }; +} + #[test] fn newlines_after_tables() { let s = " [a] foo = 1 [[b]] foo = 1 "; - assert!(s.parse::<toml::Value>().is_err()); + bad!(s, "expected newline, found an identifier at line 2"); let mut d = toml::de::Deserializer::new(s); d.set_require_newline_after_table(false); @@ -30,7 +39,10 @@ fn allow_duplicate_after_longer() { [dependencies] bitflags = 1 "; - assert!(s.parse::<toml::Value>().is_err()); + bad!( + s, + "redefinition of table `dependencies` for key `dependencies` at line 8" + ); let mut d = toml::de::Deserializer::new(s); d.set_allow_duplicate_after_longer_table(true); |