Skip to content

Commit

Permalink
Add test for Bytes created from BytesMut where offset != 0
Browse files Browse the repository at this point in the history
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
  • Loading branch information
NobodyXu committed Jul 10, 2022
1 parent efd1d57 commit 94763c2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/test_bytes.rs
Expand Up @@ -1058,6 +1058,16 @@ fn test_bytes_into_vec() {
// shared.is_unique() = True
eprintln!("6");
assert_eq!(&*Vec::from(b1), bs);

// Test bytes_mut.SHARED_VTABLE.to_vec impl where offset != 0
let mut bytes_mut1: BytesMut = bs[..].into();
let bytes_mut2 = bytes_mut1.split_off(9);

let b1 = bytes_mut1.freeze();
let b2 = bytes_mut2.freeze();

assert_eq!(Vec::from(b2), bs[9..]);
assert_eq!(Vec::from(b1), bs[..9]);
}

#[test]
Expand Down

0 comments on commit 94763c2

Please sign in to comment.