From c8332d90c01f6558e1c13fd5ebb96e85818c71d6 Mon Sep 17 00:00:00 2001 From: Dan Griffin Date: Wed, 24 May 2023 22:48:35 +0500 Subject: [PATCH] Add tests for comments and processing instructions in XML prolog See failures (2): xml_prolog::comments xml_prolog::pi --- tests/serde-de.rs | 74 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/tests/serde-de.rs b/tests/serde-de.rs index 7b12fd02..554abac4 100644 --- a/tests/serde-de.rs +++ b/tests/serde-de.rs @@ -6496,3 +6496,77 @@ mod resolve { ); } } + +/// Tests for https://github.com/tafia/quick-xml/pull/603. +/// +/// According to comments, +/// processing instructions and spaces are possible after XML declaration or DTD. +/// Their existence should not break deserializing +/// +/// ```text +/// [22] prolog ::= XMLDecl Misc* (doctypedecl Misc*)? +/// [27] Misc ::= Comment | PI | S +/// ``` +mod xml_prolog { + use super::*; + use pretty_assertions::assert_eq; + use std::collections::HashMap; + + #[test] + fn spaces() { + assert_eq!( + from_str::>( + r#" + + + + + + + "# + ) + .unwrap(), + HashMap::new() + ); + } + + #[test] + fn comments() { + assert_eq!( + from_str::>( + r#" + + + + + + + + + "#, + ) + .unwrap(), + HashMap::new() + ); + } + + #[test] + fn pi() { + assert_eq!( + from_str::>( + r#" + + + + + + + + + "#, + ) + .unwrap(), + HashMap::new() + ); + } +}