Skip to content

Commit 13ba048

Browse files
committed
Implove create random strings
1 parent d27cfa0 commit 13ba048

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ext/mbstring/tests/mb_levenshtein.phpt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ var_dump(mb_levenshtein("cafe", $cafe, encoding: "ISO-8859-1"));
5959
echo '--- Usecase of userland code ---' . \PHP_EOL;
6060

6161
for ($i = 0; $i < 100; $i++) {
62-
$bytes = implode("", array_map(function ($byte) { return mb_chr(intval(bin2hex($byte), 16), "UTF-8"); }, str_split(random_bytes(10))));
62+
$bytes = "";
63+
for ($j = 0; $j < 10; $j++) {
64+
$bytes .= mb_chr(mt_rand(0, 0x10FFF), "UTF-32");
65+
}
66+
$bytes = mb_convert_encoding($bytes, "UTF-8", "UTF-32");
6367
$compare = "あいうえおABCDEF";
6468
if (mb_levenshtein($bytes, $compare) !== keinos_mb_levenshtein($bytes, $compare)) {
6569
throw Exception("mb_levenshtein compare error: {$bytes}");

0 commit comments

Comments
 (0)