1
Fork 0

core: panic on overflow in BorrowedCursor

This commit is contained in:
joboet 2024-04-11 18:33:46 +02:00
parent 05ccc49a44
commit 91fe6f9343
No known key found for this signature in database
GPG key ID: 704E0149B0194B3C
2 changed files with 12 additions and 2 deletions

View file

@ -209,6 +209,15 @@ fn read_buf_exact() {
assert_eq!(c.read_buf_exact(buf.unfilled()).unwrap_err().kind(), io::ErrorKind::UnexpectedEof);
}
#[test]
#[should_panic]
fn borrowed_cursor_advance_overflow() {
let mut buf = [0; 512];
let mut buf = BorrowedBuf::from(&mut buf[..]);
buf.unfilled().advance(1);
buf.unfilled().advance(usize::MAX);
}
#[test]
fn take_eof() {
struct R;