Skip to content

make utf8_char_counts test faster in Miri #95532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions library/alloc/tests/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2234,11 +2234,14 @@ fn utf8_chars() {
#[test]
fn utf8_char_counts() {
let strs = [("e", 1), ("é", 1), ("€", 1), ("\u{10000}", 1), ("eé€\u{10000}", 4)];
let mut reps =
[8, 64, 256, 512, 1024].iter().copied().flat_map(|n| n - 8..=n + 8).collect::<Vec<usize>>();
let spread = if cfg!(miri) { 4 } else { 8 };
let mut reps = [8, 64, 256, 512]
.iter()
.copied()
.flat_map(|n| n - spread..=n + spread)
.collect::<Vec<usize>>();
if cfg!(not(miri)) {
let big = 1 << 16;
reps.extend(big - 8..=big + 8);
reps.extend([1024, 1 << 16].iter().copied().flat_map(|n| n - spread..=n + spread));
}
let counts = if cfg!(miri) { 0..1 } else { 0..8 };
let padding = counts.map(|len| " ".repeat(len)).collect::<Vec<String>>();
Expand Down