Cover scoped stale-byte deallocation
This commit is contained in:
@@ -924,6 +924,26 @@ fn test_scoped_guard_restores_after_panic_and_clears_stale_bytes() {
|
||||
assert_eq!(erased.capacity(), retained_capacity);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_scoped_stale_bytes_are_safely_deallocated() {
|
||||
let erased = {
|
||||
let borrowed = String::from("borrowed");
|
||||
let mut erased = TypeErasedVec::new(Vec::<&'static str>::with_capacity(2));
|
||||
|
||||
{
|
||||
let mut guard = erased.as_type_scoped::<&str>();
|
||||
guard.push(&borrowed);
|
||||
assert_eq!(guard.as_slice(), &["borrowed"]);
|
||||
}
|
||||
|
||||
erased
|
||||
};
|
||||
|
||||
assert_eq!(erased.length(), 1);
|
||||
assert_eq!(erased.capacity(), 2);
|
||||
drop(erased);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_unchecked_methods() {
|
||||
let vec = vec![123_u32];
|
||||
|
||||
Reference in New Issue
Block a user