Ejemplo n.º 1
0
 public function test_integer_with_range()
 {
     $count = 10000;
     $buckets = array_fill(100, 101, 0);
     for ($i = 0; $i < $count; $i++) {
         $number = PHPRandom::getInteger(100, 200);
         $this->assertEquals(true, isset($buckets[$number]));
         $buckets[$number]++;
     }
     $distribution = 0;
     for ($i = 100; $i < 200; $i++) {
         if ($buckets[$i] > $count / 100 * 0.5) {
             $distribution++;
         }
         if ($buckets[$i] < $count / 100 * 1.5) {
             $distribution++;
         }
     }
     $this->assertGreaterThan(100, $distribution);
 }