Skip to content

Commit 8f30b87

Browse files
committed
Add additional tests for error precedence
failures (1): struct_::non_closed::missing_field
1 parent cd0793e commit 8f30b87

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/serde-de.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3480,6 +3480,18 @@ macro_rules! maplike_errors {
34803480
mod non_closed {
34813481
use super::*;
34823482

3483+
/// For struct we expect that error about not closed tag appears
3484+
/// earlier than error about missing fields
3485+
#[test]
3486+
fn missing_field() {
3487+
let data = from_str::<$type>(r#"<root>"#);
3488+
3489+
match data {
3490+
Err(DeError::UnexpectedEof) => (),
3491+
_ => panic!("Expected `UnexpectedEof`, found {:?}", data),
3492+
}
3493+
}
3494+
34833495
#[test]
34843496
fn attributes() {
34853497
let data = from_str::<$type>(r#"<root float="42" string="answer">"#);
@@ -3515,6 +3527,18 @@ macro_rules! maplike_errors {
35153527
use super::*;
35163528
use quick_xml::Error::EndEventMismatch;
35173529

3530+
/// For struct we expect that error about mismatched tag appears
3531+
/// earlier than error about missing fields
3532+
#[test]
3533+
fn missing_field() {
3534+
let data = from_str::<$type>(r#"<root></mismatched>"#);
3535+
3536+
match data {
3537+
Err(DeError::InvalidXml(EndEventMismatch { .. })) => (),
3538+
_ => panic!("Expected `InvalidXml(EndEventMismatch)`, found {:?}", data),
3539+
}
3540+
}
3541+
35183542
#[test]
35193543
fn attributes() {
35203544
let data = from_str::<$type>(

0 commit comments

Comments
 (0)