Skip to content

Commit 002aaf2

Browse files
committed
Ensure non-power-of-two sizes are tested in the Chars::count test
1 parent ed01324 commit 002aaf2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

library/alloc/tests/str.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -2234,9 +2234,11 @@ fn utf8_chars() {
22342234
#[test]
22352235
fn utf8_char_counts() {
22362236
let strs = [("e", 1), ("é", 1), ("€", 1), ("\u{10000}", 1), ("eé€\u{10000}", 4)];
2237-
let mut reps = vec![1, 8, 64, 256, 512, 1024];
2237+
let mut reps =
2238+
[8, 64, 256, 512, 1024].iter().copied().flat_map(|n| n - 8..=n + 8).collect::<Vec<usize>>();
22382239
if cfg!(not(miri)) {
2239-
reps.push(1 << 16);
2240+
let big = 1 << 16;
2241+
reps.extend(big - 8..=big + 8);
22402242
}
22412243
let counts = if cfg!(miri) { 0..1 } else { 0..8 };
22422244
let padding = counts.map(|len| " ".repeat(len)).collect::<Vec<String>>();

0 commit comments

Comments
 (0)