public function testRandomHex()
{
$this->specify("hex does not generate a valid string", function () {
$lens = [3, 6, 130, 19, 710, 943087];
$random = new Random();
$checkSize = function ($hex, $len) {
return strlen($hex) == $len * 2;
};
$isValid = function ($hex) {
return preg_match("#^[^0-9a-f]+\$#i", $hex) === 0;
};
foreach ($lens as $len) {
$actual = $random->hex($len);
expect($checkSize($actual, $len))->true();
expect($isValid($actual))->true();
}
$actual = $random->hex();
expect($checkSize($actual, 16))->true();
expect($isValid($actual))->true();
});
}