Skip to content

Commit 1f83ed2

Browse files
committed
Move pop_if tests to end of file
1 parent 949a1e2 commit 1f83ed2

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

library/alloc/tests/vec.rs

+19-19
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,6 @@ impl Drop for DropCounter<'_> {
2828
}
2929
}
3030

31-
#[test]
32-
fn test_pop_if() {
33-
let mut v = vec![1, 2, 3, 4];
34-
let pred = |x: &mut i32| *x % 2 == 0;
35-
36-
assert_eq!(v.pop_if(pred), Some(4));
37-
assert_eq!(v, [1, 2, 3]);
38-
39-
assert_eq!(v.pop_if(pred), None);
40-
assert_eq!(v, [1, 2, 3]);
41-
}
42-
43-
#[test]
44-
fn test_pop_if_empty() {
45-
let mut v = Vec::<i32>::new();
46-
assert_eq!(v.pop_if(|_| true), None);
47-
assert!(v.is_empty());
48-
}
49-
5031
#[test]
5132
fn test_small_vec_struct() {
5233
assert_eq!(size_of::<Vec<u8>>(), size_of::<usize>() * 3);
@@ -2663,6 +2644,25 @@ fn test_vec_from_array_mut_ref() {
26632644
assert_eq!(Vec::from(&mut [1, 2, 3]), vec![1, 2, 3]);
26642645
}
26652646

2647+
#[test]
2648+
fn test_pop_if() {
2649+
let mut v = vec![1, 2, 3, 4];
2650+
let pred = |x: &mut i32| *x % 2 == 0;
2651+
2652+
assert_eq!(v.pop_if(pred), Some(4));
2653+
assert_eq!(v, [1, 2, 3]);
2654+
2655+
assert_eq!(v.pop_if(pred), None);
2656+
assert_eq!(v, [1, 2, 3]);
2657+
}
2658+
2659+
#[test]
2660+
fn test_pop_if_empty() {
2661+
let mut v = Vec::<i32>::new();
2662+
assert_eq!(v.pop_if(|_| true), None);
2663+
assert!(v.is_empty());
2664+
}
2665+
26662666
/// This assortment of tests, in combination with miri, verifies we handle UB on fishy arguments
26672667
/// in the stdlib. Draining and extending the allocation are fairly well-tested earlier, but
26682668
/// `vec.insert(usize::MAX, val)` once slipped by!

0 commit comments

Comments
 (0)