We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ae4d89d commit 0d3eaa8Copy full SHA for 0d3eaa8
library/alloc/src/collections/binary_heap/tests.rs
@@ -474,6 +474,23 @@ fn test_retain() {
474
assert!(a.is_empty());
475
}
476
477
+#[test]
478
+fn test_retain_catch_unwind() {
479
+ let mut heap = BinaryHeap::from(vec![3, 1, 2]);
480
+
481
+ // Removes the 3, then unwinds out of retain.
482
+ let _ = catch_unwind(AssertUnwindSafe(|| {
483
+ heap.retain(|e| {
484
+ if *e == 1 {
485
+ panic!();
486
+ }
487
+ false
488
+ });
489
+ }));
490
491
+ assert_eq!(heap.into_vec(), [1, 2]); // BAD!!
492
+}
493
494
// old binaryheap failed this test
495
//
496
// Integrity means that all elements are present after a comparison panics,
0 commit comments