Skip to content

Commit

Permalink
add another test to make sure it still works with full reads
Browse files Browse the repository at this point in the history
  • Loading branch information
conradludgate committed Feb 3, 2024
1 parent a27e45a commit f923e7a
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions library/std/src/io/tests.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -666,5 +666,19 @@ fn read_buf_broken_read() {
}
}

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> {
// broken length calculation
Ok(buf.len())
}
}

assert_eq!(BufReader::new(FullRead).fill_buf().unwrap().len(), DEFAULT_BUF_SIZE);
}

0 comments on commit f923e7a

Please sign in to comment.