Skip to content

Commit f45ec8b

Browse files
committed
Remove special case from tests
1 parent 0febc2b commit f45ec8b

File tree

3 files changed

+8
-24
lines changed

3 files changed

+8
-24
lines changed

tests/documents/sample_1_full.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
StartDocument(1.0, utf-8)
2+
Characters(
3+
)
24
StartElement(project [name="project-name"])
35
Characters(
46
)

tests/documents/sample_2_full.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
StartDocument(1.0, utf-8)
2+
Characters(
3+
)
24
StartElement({urn:example:namespace}p:data)
35
Characters(
46
)

tests/xmlrs_reader_tests.rs

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -355,21 +355,15 @@ fn default_namespace_applies_to_end_elem() {
355355
}
356356

357357
#[track_caller]
358-
fn test(input: &str, output: &str, is_short: bool) {
359-
test_bytes(input.as_bytes(), output.as_bytes(), is_short);
358+
fn test(input: &str, output: &str, trim: bool) {
359+
test_bytes(input.as_bytes(), output.as_bytes(), trim);
360360
}
361361

362362
#[track_caller]
363-
fn test_bytes(input: &[u8], output: &[u8], is_short: bool) {
364-
// Normalize newlines on Windows to just \n, which is what the reader and
365-
// writer use.
366-
// let input = input.replace("\r\n", "\n");
367-
// let input = input.as_bytes();
368-
// let output = output.replace("\r\n", "\n");
369-
// let output = output.as_bytes();
363+
fn test_bytes(input: &[u8], output: &[u8], trim: bool) {
370364
let mut reader = Reader::from_reader(input);
371365
reader
372-
.trim_text(is_short)
366+
.trim_text(trim)
373367
.check_comments(true)
374368
.expand_empty_elements(false);
375369

@@ -402,20 +396,6 @@ fn test_bytes(input: &[u8], output: &[u8], is_short: bool) {
402396
}
403397
panic!("Unexpected event: {}", line);
404398
}
405-
406-
if !is_short && line.starts_with("StartDocument") {
407-
// advance next Characters(empty space) ...
408-
if let Ok(Event::Text(ref e)) = reader.read_event(&mut Vec::new()) {
409-
if e.iter().any(|b| match *b {
410-
b' ' | b'\r' | b'\n' | b'\t' => false,
411-
_ => true,
412-
}) {
413-
panic!("Reader expects empty Text event after a StartDocument");
414-
}
415-
} else {
416-
panic!("Reader expects empty Text event after a StartDocument");
417-
}
418-
}
419399
}
420400
}
421401

0 commit comments

Comments
 (0)