protected function doTestGenerate(\RandomLib\Generator $generator, $times)
 {
     $inside = 0;
     $outside = 0;
     $on = 0;
     for ($i = 0; $i < $times; $i++) {
         $byte = $generator->generate(2);
         $byte = unpack('n', $byte);
         $byte = array_shift($byte);
         $xCoord = $byte >> 8;
         $yCoord = $byte & 0xff;
         if ($xCoord < $yCoord) {
             $outside++;
         } elseif ($xCoord == $yCoord) {
             $on++;
         } else {
             $inside++;
         }
     }
     $this->assertGreaterThan(0, $outside, 'Outside Is 0');
     $this->assertGreaterThan(0, $inside, 'Inside Is 0');
     $ratio = $inside / $outside;
     return $ratio;
 }
Beispiel #2
0
 /**
  * Generates a string of random binary data of the specified length
  *
  * @param integer $length The number of bytes of random binary data to generate
  * @return string A binary string
  */
 public function generate($length)
 {
     return $this->generator->generate($length);
 }