Skip to content

Commit 7c9ad34

Browse files
committed
Move BufRead::skip_until test to a more appropriate location
1 parent 4eea976 commit 7c9ad34

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

library/std/src/io/buffered/tests.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -400,34 +400,6 @@ fn test_read_until() {
400400
assert_eq!(v, []);
401401
}
402402

403-
#[test]
404-
fn test_skip_until() {
405-
let bytes: &[u8] = b"read\0ignore\0read\0ignore\0read\0ignore";
406-
let mut reader = BufReader::new(bytes);
407-
408-
// read from the bytes, alternating between
409-
// consuming `read\0`s and skipping `ignore\0`s
410-
loop {
411-
// consume `read\0`
412-
let mut out = Vec::new();
413-
let read = reader.read_until(0, &mut out).unwrap();
414-
if read == 0 {
415-
// eof
416-
break;
417-
} else {
418-
assert_eq!(out, b"read\0");
419-
}
420-
421-
// skip past `ignore\0`
422-
reader.skip_until(0).unwrap();
423-
}
424-
425-
// ensure we are at the end of the byte slice and that we can skip no further
426-
// also ensure skip_until matches the behavior of read_until at EOF
427-
let skipped = reader.skip_until(0).unwrap();
428-
assert_eq!(skipped, 0);
429-
}
430-
431403
#[test]
432404
fn test_line_buffer() {
433405
let mut writer = LineWriter::new(Vec::new());

library/std/src/io/tests.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,34 @@ fn read_until() {
2525
assert_eq!(v, []);
2626
}
2727

28+
#[test]
29+
fn skip_until() {
30+
let bytes: &[u8] = b"read\0ignore\0read\0ignore\0read\0ignore";
31+
let mut reader = BufReader::new(bytes);
32+
33+
// read from the bytes, alternating between
34+
// consuming `read\0`s and skipping `ignore\0`s
35+
loop {
36+
// consume `read\0`
37+
let mut out = Vec::new();
38+
let read = reader.read_until(0, &mut out).unwrap();
39+
if read == 0 {
40+
// eof
41+
break;
42+
} else {
43+
assert_eq!(out, b"read\0");
44+
}
45+
46+
// skip past `ignore\0`
47+
reader.skip_until(0).unwrap();
48+
}
49+
50+
// ensure we are at the end of the byte slice and that we can skip no further
51+
// also ensure skip_until matches the behavior of read_until at EOF
52+
let skipped = reader.skip_until(0).unwrap();
53+
assert_eq!(skipped, 0);
54+
}
55+
2856
#[test]
2957
fn split() {
3058
let buf = Cursor::new(&b"12"[..]);

0 commit comments

Comments
 (0)