Skip to content

Commit 4c694db

Browse files
committed
add another test to make sure it still works with full reads
1 parent a27e45a commit 4c694db

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

library/std/src/io/tests.rs

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::{repeat, BorrowedBuf, Cursor, SeekFrom};
22
use crate::cmp::{self, min};
3-
use crate::io::{self, IoSlice, IoSliceMut};
3+
use crate::io::{self, IoSlice, IoSliceMut, DEFAULT_BUF_SIZE};
44
use crate::io::{BufRead, BufReader, Read, Seek, Write};
55
use crate::mem::MaybeUninit;
66
use crate::ops::Deref;
@@ -666,5 +666,18 @@ fn read_buf_broken_read() {
666666
}
667667
}
668668

669-
BufReader::new(MalformedRead).read(&mut [0; 4]).unwrap();
669+
let _ = BufReader::new(MalformedRead).fill_buf();
670+
}
671+
672+
#[test]
673+
fn read_buf_full_read() {
674+
struct FullRead;
675+
676+
impl Read for FullRead {
677+
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
678+
Ok(buf.len())
679+
}
680+
}
681+
682+
assert_eq!(BufReader::new(FullRead).fill_buf().unwrap().len(), DEFAULT_BUF_SIZE);
670683
}

0 commit comments

Comments
 (0)