Add test for VecDeque::append ZST capacity overflow

This commit is contained in:
pommicket 2023-02-25 13:50:56 -05:00
parent 379b18bb0a
commit 12f959ba39
1 changed files with 14 additions and 0 deletions

View File

@ -1045,6 +1045,20 @@ fn test_append_double_drop() {
assert_eq!(count_b, 1);
}
#[test]
#[should_panic]
fn test_append_zst_capacity_overflow() {
let mut v = Vec::with_capacity(usize::MAX);
// note: using resize instead of set_len here would
// be *extremely* slow in unoptimized builds.
// SAFETY: `v` has capacity `usize::MAX`, and no initialization
// is needed for empty tuples.
unsafe { v.set_len(usize::MAX) };
let mut v = VecDeque::from(v);
let mut w = vec![()].into();
v.append(&mut w);
}
#[test]
fn test_retain() {
let mut buf = VecDeque::new();