Skip to content

Commit b0ae04c

Browse files
committed
tests retain
1 parent 61c2a48 commit b0ae04c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/libcore/tests/slice.rs

+11
Original file line numberDiff line numberDiff line change
@@ -1635,6 +1635,17 @@ fn test_slice_partition_dedup_partialeq() {
16351635
assert_eq!(duplicates, [Foo(0, 5), Foo(1, 9)]);
16361636
}
16371637

1638+
#[test]
1639+
fn test_slice_retain() {
1640+
let mut slice = [1, 2, 2, 3, 1, 4];
1641+
let retained = slice.retain(|&x| x == 1);
1642+
assert_eq!(retained, &[1, 1]);
1643+
1644+
let mut slice = [1, 2, 2, 3, 1, 4];
1645+
let retained = slice.retain(|&x| x % 2 == 0);
1646+
assert_eq!(retained, &[2, 2, 4]);
1647+
}
1648+
16381649
#[test]
16391650
fn test_copy_within() {
16401651
// Start to end, with a RangeTo.

0 commit comments

Comments
 (0)