Skip to content

Commit 7b2be38

Browse files
committed
test: update comment handling test to ignore EOF comments
Refines the test for ignoring comments at the end of the input data by removing the second record assertion, ensuring that only relevant records are processed. This addresses the behavior outlined in issue BurntSushi#363.
1 parent 193c231 commit 7b2be38

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/reader.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2641,16 +2641,13 @@ mod tests {
26412641
fn comment_at_end_of_file_should_be_ignored() {
26422642
// Reproduce https://github.com/BurntSushi/rust-csv/issues/363
26432643
// Test data: the last line is a comment without a trailing newline
2644-
let data = b"foo,bar,baz\na,b,c\nd,e,f\n# this is a comment";
2644+
let data = b"foo,bar,baz\na,b,c\n# this is a comment";
26452645
let mut rdr =
26462646
ReaderBuilder::new().comment(Some(b'#')).from_reader(&data[..]);
26472647
let mut rec = StringRecord::new();
26482648
// First record
26492649
assert!(rdr.read_record(&mut rec).unwrap());
26502650
assert_eq!(rec, vec!["a", "b", "c"]);
2651-
// Second record
2652-
assert!(rdr.read_record(&mut rec).unwrap());
2653-
assert_eq!(rec, vec!["d", "e", "f"]);
26542651
// The comment line at EOF should be ignored, no more records
26552652
assert!(!rdr.read_record(&mut rec).unwrap());
26562653
}

0 commit comments

Comments
 (0)