Skip to content

Commit

Permalink
Add regression test for tafia#683
Browse files Browse the repository at this point in the history
failures:
    issue683
  • Loading branch information
Mingun committed Apr 29, 2024
1 parent 2771aeb commit 8d86e90
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/serde-issues.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,3 +462,35 @@ fn issue580() {
}
);
}

/// Regression test for https://github.com/tafia/quick-xml/issues/683.
#[test]
fn issue683() {
#[derive(Deserialize, Debug, PartialEq)]
enum ScheduleLocation {
#[serde(rename = "DT")]
Destination,
}

#[derive(Deserialize, Debug, PartialEq)]
#[allow(non_snake_case)]
struct Schedule {
cancelReason: Option<u32>,
#[serde(rename = "$value")]
locations: Vec<ScheduleLocation>,
}
let xml = r#"
<schedule xmlns:ns2="http://www.thalesgroup.com/rtti/PushPort/Schedules/v3">
<ns2:DT/>
<ns2:cancelReason>918</ns2:cancelReason>
</schedule>"#;
let result = quick_xml::de::from_str::<Schedule>(xml);
dbg!(&result);
assert_eq!(
result.unwrap(),
Schedule {
cancelReason: Some(918),
locations: vec![ScheduleLocation::Destination],
}
);
}

0 comments on commit 8d86e90

Please sign in to comment.