Skip to content

Commit

Permalink
Panic safety test for SmallVec::drop
Browse files Browse the repository at this point in the history
A test for issue servo#14
  • Loading branch information
root committed Aug 20, 2015
1 parent 3e329f0 commit 134a8f7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,4 +578,21 @@ pub mod tests {

assert_eq!(&v.iter().map(|v| **v).collect::<Vec<_>>(), &[0, 3, 2]);
}

#[test]
#[should_panic]
fn test_drop_panic_smallvec() {
// This test should only panic once, and not double panic,
// which would mean a double drop
struct DropPanic;

impl Drop for DropPanic {
fn drop(&mut self) {
panic!("drop");
}
}

let mut v = SmallVec::<[_; 1]>::new();
v.push(DropPanic);
}
}

0 comments on commit 134a8f7

Please sign in to comment.