1--TEST--
2Random: Randomizer: getBytes(): Basic functionality
3--FILE--
4<?php
5
6use Random\Engine;
7use Random\Engine\Mt19937;
8use Random\Engine\PcgOneseq128XslRr64;
9use Random\Engine\Secure;
10use Random\Engine\Test\TestShaEngine;
11use Random\Engine\Xoshiro256StarStar;
12use Random\Randomizer;
13
14require __DIR__ . "/../../engines.inc";
15
16$engines = [];
17$engines[] = new Mt19937(null, MT_RAND_MT19937);
18$engines[] = new Mt19937(null, MT_RAND_PHP);
19$engines[] = new PcgOneseq128XslRr64();
20$engines[] = new Xoshiro256StarStar();
21$engines[] = new Secure();
22$engines[] = new TestShaEngine();
23
24foreach ($engines as $engine) {
25    echo $engine::class, PHP_EOL;
26
27    $randomizer = new Randomizer($engine);
28
29    // Using 10_000 is very slow.
30    for ($i = 1; $i < 1_000; $i++) {
31        if (\strlen($randomizer->getBytes($i)) !== $i) {
32            die("failure: incorrect string length at {$i}");
33        }
34    }
35}
36
37die('success');
38
39?>
40--EXPECT--
41Random\Engine\Mt19937
42Random\Engine\Mt19937
43Random\Engine\PcgOneseq128XslRr64
44Random\Engine\Xoshiro256StarStar
45Random\Engine\Secure
46Random\Engine\Test\TestShaEngine
47success
48