Add a test for Reader::advance
This commit is contained in:
parent
3f3e98d190
commit
bcfbe99d2b
|
@ -333,6 +333,17 @@ mod tests {
|
|||
assert_eq!(bc.total_len(), 7);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn advance_too_far() {
|
||||
let bytes = b"12345";
|
||||
let mut r = Reader::from_slice(&bytes[..]);
|
||||
assert_eq!(r.remaining(), 5);
|
||||
assert_eq!(r.advance(6), Err(Error::Truncated));
|
||||
assert_eq!(r.remaining(), 5);
|
||||
assert_eq!(r.advance(5), Ok(()));
|
||||
assert_eq!(r.remaining(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn truncate() {
|
||||
let bytes = b"Hello universe!!!1!";
|
||||
|
|
Loading…
Reference in New Issue