示例#1
0
 function testQuickFindRandom()
 {
     $trials = 100;
     for ($i = 0; $i < $trials; $i++) {
         $size = rand(1, 10);
         $shuffled = QuickSort::shuffle(range(1, 10));
         $x = rand(1, $size);
         $q = new QuickSort($shuffled);
         $y = $q->find($x);
         $this->assertEquals($x, $y, "Quick find found incorrect value for {$x} th item in list");
     }
 }