Skip to content

Fix #443: Keep LF eol for all test documents, explicitly mark encoding for UTF-16 documents #454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# Unit tests assume that all xml files have unix style line endings
*.xml text eol=cr
/tests/documents/* text eol=lf

/tests/documents/utf16be.xml binary
/tests/documents/utf16le.xml binary
/tests/documents/sample_5_utf16bom.xml binary
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@
- [#407]: Improved benchmark suite to cover whole-document parsing, escaping and unescaping text
- [#418]: Parameterized macrobenchmarks and comparative benchmarks, added throughput measurements via criterion
- [#434]: Added more tests for serde deserializer
- [#443]: Now all documents in `/tests/documents` are checked out with LF eol in working copy (except sample_5_utf16bom.xml)

[#8]: https://github.com/Mingun/fast-xml/pull/8
[#9]: https://github.com/Mingun/fast-xml/pull/9
Expand All @@ -216,6 +217,7 @@
[#437]: https://github.com/tafia/quick-xml/pull/437
[#439]: https://github.com/tafia/quick-xml/pull/439
[#440]: https://github.com/tafia/quick-xml/pull/440
[#443]: https://github.com/tafia/quick-xml/pull/443


## 0.23.0 -- 2022-05-08
Expand Down
15 changes: 0 additions & 15 deletions tests/unit_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,6 @@ fn test_writer_borrow() -> Result<()> {
#[test]
fn test_writer_indent() -> Result<()> {
let txt = include_str!("../tests/documents/test_writer_indent.xml");
// Normalize newlines on Windows to just \n, which is what the reader and
// writer use.
let normalized_txt = txt.replace("\r\n", "\n");
let txt = normalized_txt.as_str();
let mut reader = Reader::from_str(txt);
reader.trim_text(true);
let mut writer = Writer::new_with_indent(Cursor::new(Vec::new()), b' ', 4);
Expand All @@ -250,12 +246,6 @@ fn test_writer_indent() -> Result<()> {
}

let result = writer.into_inner().into_inner();
// println!("{:?}", String::from_utf8_lossy(&result));

#[cfg(windows)]
assert!(result.into_iter().eq(txt.bytes().filter(|b| *b != 13)));

#[cfg(not(windows))]
assert_eq!(result, txt.as_bytes());

Ok(())
Expand All @@ -275,11 +265,6 @@ fn test_writer_indent_cdata() -> Result<()> {
}

let result = writer.into_inner().into_inner();

#[cfg(windows)]
assert!(result.into_iter().eq(txt.bytes().filter(|b| *b != 13)));

#[cfg(not(windows))]
assert_eq!(result, txt.as_bytes());

Ok(())
Expand Down