]> git.lizzy.rs Git - rust.git/commitdiff
Ensure non-power-of-two sizes are tested in the Chars::count test
authorThom Chiovoloni <chiovolonit@gmail.com>
Sat, 30 Oct 2021 21:04:49 +0000 (14:04 -0700)
committerThom Chiovoloni <chiovolonit@gmail.com>
Sat, 5 Feb 2022 19:15:18 +0000 (11:15 -0800)
library/alloc/tests/str.rs

index 3dcbc54be4e8d79dcc919401f13fd2ac55547725..7b07821ab1d31de590cb9e38ab45f6bf40bc90f3 100644 (file)
@@ -2234,9 +2234,11 @@ fn utf8_chars() {
 #[test]
 fn utf8_char_counts() {
     let strs = [("e", 1), ("é", 1), ("€", 1), ("\u{10000}", 1), ("eé€\u{10000}", 4)];
-    let mut reps = vec![1, 8, 64, 256, 512, 1024];
+    let mut reps =
+        [8, 64, 256, 512, 1024].iter().copied().flat_map(|n| n - 8..=n + 8).collect::<Vec<usize>>();
     if cfg!(not(miri)) {
-        reps.push(1 << 16);
+        let big = 1 << 16;
+        reps.extend(big - 8..=big + 8);
     }
     let counts = if cfg!(miri) { 0..1 } else { 0..8 };
     let padding = counts.map(|len| " ".repeat(len)).collect::<Vec<String>>();