add another test to make sure it still works with full reads

This commit is contained in:
Conrad Ludgate 2024-02-03 11:44:13 +00:00
parent a27e45a71b
commit 4c694db252

View File

@ -1,6 +1,6 @@
use super::{repeat, BorrowedBuf, Cursor, SeekFrom};
use crate::cmp::{self, min};
use crate::io::{self, IoSlice, IoSliceMut};
use crate::io::{self, IoSlice, IoSliceMut, DEFAULT_BUF_SIZE};
use crate::io::{BufRead, BufReader, Read, Seek, Write};
use crate::mem::MaybeUninit;
use crate::ops::Deref;
@ -666,5 +666,18 @@ fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
}
}
BufReader::new(MalformedRead).read(&mut [0; 4]).unwrap();
let _ = BufReader::new(MalformedRead).fill_buf();
}
#[test]
fn read_buf_full_read() {
struct FullRead;
impl Read for FullRead {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
Ok(buf.len())
}
}
assert_eq!(BufReader::new(FullRead).fill_buf().unwrap().len(), DEFAULT_BUF_SIZE);
}