Skip to content

Commit 1f6f917

Browse files
committed
Added test for issue #78498
1 parent e83666f commit 1f6f917

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

library/alloc/tests/string.rs

+15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::borrow::Cow;
22
use std::collections::TryReserveError::*;
33
use std::ops::Bound::*;
4+
use std::panic;
45

56
pub trait IntoCow<'a, B: ?Sized>
67
where
@@ -378,6 +379,20 @@ fn test_retain() {
378379

379380
s.retain(|_| false);
380381
assert_eq!(s, "");
382+
383+
let mut s = String::from("0è0");
384+
let _ = panic::catch_unwind(panic::AssertUnwindSafe(|| {
385+
let mut count = 0;
386+
s.retain(|_| {
387+
count += 1;
388+
match count {
389+
1 => false,
390+
2 => true,
391+
_ => panic!(),
392+
}
393+
});
394+
}));
395+
assert!(std::str::from_utf8(s.as_bytes()).is_ok());
381396
}
382397

383398
#[test]

0 commit comments

Comments
 (0)