Skip to content
This repository has been archived by the owner on May 30, 2022. It is now read-only.

Commit

Permalink
Add tests for tafia/quick-xml#344
Browse files Browse the repository at this point in the history
failures (8):
    reader::test::borrowed::issue_344::cdata
    reader::test::borrowed::issue_344::comment
    reader::test::borrowed::issue_344::doctype_lowercase
    reader::test::borrowed::issue_344::doctype_uppercase
    reader::test::buffered::issue_344::cdata
    reader::test::buffered::issue_344::comment
    reader::test::buffered::issue_344::doctype_lowercase
    reader::test::buffered::issue_344::doctype_uppercase
  • Loading branch information
Mingun committed May 2, 2022
1 parent cf47632 commit a446a0c
Showing 1 changed file with 66 additions and 1 deletion.
67 changes: 66 additions & 1 deletion src/reader.rs
Expand Up @@ -255,7 +255,8 @@ impl<R: BufRead> Reader<R> {
}
}

/// private function to read until '>' is found
/// Private function to read until `>` is found. This function expects that
/// it was called just after encounter a `<` symbol.
fn read_until_close<'i, 'r, B>(&mut self, buf: B) -> Result<Event<'i>>
where
R: BufferedInput<'i, 'r, B>,
Expand Down Expand Up @@ -2131,6 +2132,70 @@ mod test {
}
}
}

mod issue_344 {
use crate::errors::Error;

#[test]
fn cdata() {
let doc = "![]]>";
let mut reader = crate::Reader::from_str(doc);

match reader.read_until_close($buf) {
Err(Error::UnexpectedEof(s)) if s == "CData" => {}
x => assert!(
false,
r#"Expected `UnexpectedEof("CData")`, but result is: {:?}"#,
x
),
}
}

#[test]
fn comment() {
let doc = "!- -->";
let mut reader = crate::Reader::from_str(doc);

match reader.read_until_close($buf) {
Err(Error::UnexpectedEof(s)) if s == "Comment" => {}
x => assert!(
false,
r#"Expected `UnexpectedEof("Comment")`, but result is: {:?}"#,
x
),
}
}

#[test]
fn doctype_uppercase() {
let doc = "!D>";
let mut reader = crate::Reader::from_str(doc);

match reader.read_until_close($buf) {
Err(Error::UnexpectedEof(s)) if s == "DOCTYPE" => {}
x => assert!(
false,
r#"Expected `UnexpectedEof("DOCTYPE")`, but result is: {:?}"#,
x
),
}
}

#[test]
fn doctype_lowercase() {
let doc = "!d>";
let mut reader = crate::Reader::from_str(doc);

match reader.read_until_close($buf) {
Err(Error::UnexpectedEof(s)) if s == "DOCTYPE" => {}
x => assert!(
false,
r#"Expected `UnexpectedEof("DOCTYPE")`, but result is: {:?}"#,
x
),
}
}
}
};
}

Expand Down

0 comments on commit a446a0c

Please sign in to comment.