Skip to content

Commit 7c1ab71

Browse files
committed
Add assertion to test skip_until return value
The extra `\0` in this commit is needed because the assertion on line 49 will fail otherwise (as `skip_until` stops reading on EOF and therefore does not read a trailing `\0`, returning 6 read bytes rather than the expected 7)
1 parent 1d7d765 commit 7c1ab71

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Diff for: library/std/src/io/tests.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn read_until() {
2727

2828
#[test]
2929
fn skip_until() {
30-
let bytes: &[u8] = b"read\0ignore\0read\0ignore\0read\0ignore";
30+
let bytes: &[u8] = b"read\0ignore\0read\0ignore\0read\0ignore\0";
3131
let mut reader = BufReader::new(bytes);
3232

3333
// read from the bytes, alternating between
@@ -41,10 +41,12 @@ fn skip_until() {
4141
break;
4242
} else {
4343
assert_eq!(out, b"read\0");
44+
assert_eq!(read, b"read\0".len());
4445
}
4546

4647
// skip past `ignore\0`
47-
reader.skip_until(0).unwrap();
48+
let skipped = reader.skip_until(0).unwrap();
49+
assert_eq!(skipped, b"ignore\0".len());
4850
}
4951

5052
// ensure we are at the end of the byte slice and that we can skip no further

0 commit comments

Comments
 (0)