mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-28 09:07:57 +00:00
Don't panic in serde_test
Panics lead to reporting errors in tests inside of serde_test internals, returning errors moves the report location to the corresponding assert_tokens expression
This commit is contained in:
@@ -63,14 +63,12 @@ macro_rules! assert_next_token {
|
||||
($ser:expr, $actual:expr, $pat:pat, $guard:expr) => {
|
||||
match $ser.next_token() {
|
||||
Some($pat) if $guard => {}
|
||||
Some(expected) => {
|
||||
panic!("expected Token::{} but serialized as {}",
|
||||
expected, $actual);
|
||||
}
|
||||
None => {
|
||||
panic!("expected end of tokens, but {} was serialized",
|
||||
$actual);
|
||||
}
|
||||
Some(expected) => return Err(ser::Error::custom(
|
||||
format!("expected Token::{} but serialized as {}", expected, $actual)
|
||||
)),
|
||||
None => return Err(ser::Error::custom(
|
||||
format!("expected end of tokens, but {} was serialized", $actual)
|
||||
)),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user