Add test for reading invalid XML to the end
(Review this commit with "ignore whitespace changes" option)
failures (1):
de::tests::read_to_end::invalid_xml
@@ -3079,10 +3079,13 @@ mod tests {
}
}
- #[test]
- fn read_to_end() {
+ mod read_to_end {
+ use super::*;
use crate::de::DeEvent::*;
+ use pretty_assertions::assert_eq;
+ #[test]
+ fn complex() {
let mut de = Deserializer::from_str(
r#"
<root>
@@ -3115,6 +3118,21 @@ mod tests {
assert_eq!(de.next().unwrap(), Eof);
}
+ #[test]
+ fn invalid_xml() {
+ let mut de = Deserializer::from_str("<tag><tag></tag>");
+
+ assert_eq!(de.next().unwrap(), Start(BytesStart::new("tag")));
+ assert_eq!(de.peek().unwrap(), &Start(BytesStart::new("tag")));
+
+ match de.read_to_end(QName(b"tag")) {
+ Err(DeError::UnexpectedEof) => (),
+ x => panic!("Expected `Err(UnexpectedEof)`, but found {:?}", x),
+ }
+ assert_eq!(de.next().unwrap(), Eof);
+ }
+ }
+
#[test]
fn borrowing_reader_parity() {
let s = r##"
