Skip to content

Commit

Permalink
Add tests for cases where offset != 0 for vtable in bytes.rs
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 e18c215 commit efd1d57
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/test_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1080,4 +1080,11 @@ fn test_bytes_into_vec_promotable_even() {

// Test cases where vtable = SHARED_VTABLE, kind == KIND_ARC, ref_cnt == 1
assert_eq!(Vec::from(b2), vec);

// Test cases where offset != 0
let mut b1 = Bytes::from(vec.clone());
let b2 = b1.split_off(20);

assert_eq!(Vec::from(b2), vec[20..]);
assert_eq!(Vec::from(b1), vec[..20]);
}
7 changes: 7 additions & 0 deletions tests/test_bytes_odd_alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,11 @@ fn test_bytes_into_vec() {

// Test cases where vtable = SHARED_VTABLE, kind == KIND_ARC, ref_cnt == 1
assert_eq!(Vec::from(b2), vec);

// Test cases where offset != 0
let mut b1 = Bytes::from(vec.clone());
let b2 = b1.split_off(20);

assert_eq!(Vec::from(b2), vec[20..]);
assert_eq!(Vec::from(b1), vec[..20]);
}
7 changes: 7 additions & 0 deletions tests/test_bytes_vec_alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,11 @@ fn test_bytes_into_vec() {

// Test cases where vtable = SHARED_VTABLE, kind == KIND_ARC, ref_cnt == 1
assert_eq!(Vec::from(b2), vec);

// Test cases where offset != 0
let mut b1 = Bytes::from(vec.clone());
let b2 = b1.split_off(20);

assert_eq!(Vec::from(b2), vec[20..]);
assert_eq!(Vec::from(b1), vec[..20]);
}

0 comments on commit efd1d57

Please sign in to comment.