Skip to content

Commit 9e1f715

Browse files
committed
improve tests again
1 parent fe069a7 commit 9e1f715

32 files changed

+14
-9
lines changed

ext/random/tests/randomizer/get_bytes.phpt renamed to ext/random/tests/03_randomizer/get_bytes.phpt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,31 @@ $randomizer = new \Random\Randomizer (
1010

1111
public function generate(): string
1212
{
13+
if ($this->count > 5) {
14+
die('overflow');
15+
}
16+
1317
return match ($this->count++) {
1418
0 => 'H',
1519
1 => 'e',
16-
2 => 'l',
17-
3 => 'l',
18-
4 => 'o',
19-
5 => \random_bytes(32), // 128-bit
20+
2 => 'll',
21+
3 => 'o',
22+
4 => 'abcdefghijklmnopqrstuvwxyz', // 208 bits
23+
5 => 'success',
2024
default => \random_bytes(16),
2125
};
2226
}
2327
}
2428
);
2529

26-
if ($randomizer->getBytes(5) !== 'Hello') {
27-
die('failure');
28-
}
30+
echo $randomizer->getBytes(5) . PHP_EOL; // Hello
31+
32+
echo $randomizer->getBytes(8) . PHP_EOL; // abcdefgh (64 bits)
2933

30-
$randomizer->getBytes(6);
34+
die($randomizer->getBytes(7));
3135

32-
die('success');
3336
?>
3437
--EXPECTF--
38+
Hello
39+
abcdefgh
3540
success

0 commit comments

Comments
 (0)