add another test to make sure it still works with full reads
This commit is contained in:
parent
a27e45a71b
commit
4c694db252
@ -1,6 +1,6 @@
|
|||||||
use super::{repeat, BorrowedBuf, Cursor, SeekFrom};
|
use super::{repeat, BorrowedBuf, Cursor, SeekFrom};
|
||||||
use crate::cmp::{self, min};
|
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::io::{BufRead, BufReader, Read, Seek, Write};
|
||||||
use crate::mem::MaybeUninit;
|
use crate::mem::MaybeUninit;
|
||||||
use crate::ops::Deref;
|
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);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user