コード例 #1
0
 public function provideTestComplexity()
 {
     $cases = array();
     $generator = new FixedSizeIndexGenerator();
     $generator->setIndexLength(10000);
     $cases[] = array($generator);
     return $cases;
 }
コード例 #2
0
 /**
  * Tests finding all keys with different index configurations 
  * 
  * @dataProvider provideTestIndexConfiguration
  */
 public function testIndexConfiguration($offset, $indexFieldLength, $length)
 {
     $generator = new FixedSizeIndexGenerator();
     $generator->setIndexFieldOffset($offset);
     $generator->setIndexFieldLength($indexFieldLength);
     $generator->setIndexLength($length);
     $index = $generator->getIndex();
     for ($key = 0; $key < $length; $key++) {
         $result = $index->search($key);
         $this->assertNotNull($result, "key: {$key}");
         $this->assertRegExp('/data_' . $key . '_.*\\$/s', $result->getData(), "key: {$key}");
     }
 }
コード例 #3
0
ファイル: IndexTest.php プロジェクト: malkusch/php-index
 /**
  * Test cases for testFailSearch()
  *
  * @return void
  */
 public function provideTestFailSearch()
 {
     $cases = array();
     // different sizes
     $lengths = array(0, 1, 10, IndexGenerator::getBlockSize() - 1, IndexGenerator::getBlockSize(), IndexGenerator::getBlockSize() + 1, IndexGenerator::getBlockSize() * 4);
     foreach ($lengths as $length) {
         // Fail searching for MIN(index) - 1
         $generator = new FixedSizeIndexGenerator();
         $generator->setIndexLength($length);
         $generator->getIndex();
         $cases[] = array($generator->getIndex(), $generator->getMinimum() - 1);
         // Fail searching for MAX(index) + 1
         $generator = new FixedSizeIndexGenerator();
         $generator->setIndexLength($length);
         $generator->getIndex();
         $cases[] = array($generator->getIndex(), $generator->getMaximum() + 1);
         // Fail searching for any missing key inside the index range
         $generator = new FixedSizeIndexGenerator();
         $generator->setIndexLength($length);
         $generator->setStepSize(2);
         $generator->getIndex();
         $cases[] = array($generator->getIndex(), $generator->getMaximum() / 2 + 0.1);
     }
     return $cases;
 }
コード例 #4
0
 /**
  * Test cases for testAllValidRanges()
  */
 public function provideTestAllValidRanges()
 {
     $cases = array();
     $generator = new FixedSizeIndexGenerator();
     $generator->setIndexLength(0);
     $cases[] = array($generator);
     $generator = new FixedSizeIndexGenerator();
     $generator->setIndexLength(1);
     $cases[] = array($generator);
     $generator = new FixedSizeIndexGenerator();
     $generator->setIndexLength(10);
     $cases[] = array($generator);
     $generator = new FixedSizeIndexGenerator();
     $generator->setIndexLength(100);
     $cases[] = array($generator);
     $generator = new FixedSizeIndexGenerator();
     $generator->setIndexLength(200);
     $cases[] = array($generator);
     return $cases;
 }
コード例 #5
0
ファイル: IteratorTest.php プロジェクト: malkusch/php-index
 /**
  * Provides test cases above 1000
  * 
  * @return array
  */
 public function provideLargerTestCases()
 {
     $cases = $this->provideTestCases();
     // 1000 entries
     $generator = new FixedSizeIndexGenerator();
     $generator->setIndexLength(1000);
     $cases[] = array($generator);
     // 10000 entries
     $generator = new FixedSizeIndexGenerator();
     $generator->setIndexLength(10000);
     $cases[] = array($generator);
     return $cases;
 }