Skip to content

Commit

Permalink
Test VecDeque append not dropping twice
Browse files Browse the repository at this point in the history
  • Loading branch information
Pazzaz committed Aug 15, 2018
1 parent 7662528 commit b063bd4
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/liballoc/tests/vec_deque.rs
Expand Up @@ -1004,6 +1004,31 @@ fn test_append_permutations() {
}
}

struct DropCounter<'a> {
count: &'a mut u32,
}

impl<'a> Drop for DropCounter<'a> {
fn drop(&mut self) {
*self.count += 1;
}
}

#[test]
fn test_append_double_drop() {
let (mut count_a, mut count_b) = (0, 0);
{
let mut a = VecDeque::new();
let mut b = VecDeque::new();
a.push_back(DropCounter { count: &mut count_a });
b.push_back(DropCounter { count: &mut count_b });

a.append(&mut b);
}
assert_eq!(count_a, 1);
assert_eq!(count_b, 1);
}

#[test]
fn test_retain() {
let mut buf = VecDeque::new();
Expand Down

0 comments on commit b063bd4

Please sign in to comment.