Beispiel #1
0
test_start('clearTargets');
test_step($chash->clearTargets(), 'targets count is still ' . $chash->getTargetsCount());
test_end('');
test_start('setTargets');
$targets = array();
for ($index = 1; $index <= TARGETS; $index++) {
    $targets[sprintf('target%03d', $index)] = 1;
}
test_step(($count = $chash->setTargets($targets)) < 0 ? $count : 0);
test_end('set ' . $count . ' targets');
test_start('serialize');
test_step(($serialized1 = $chash->serialize()) == '' ? -1 : 0);
test_end('serialized size is ' . strlen($serialized1) . ' bytes');
$chash = new CHash();
test_start('unserialize');
test_step(($count = $chash->unserialize($serialized1)) < 0 ? $count : 0);
test_end('continuum count is ' . $count);
test_start('serialize coherency');
test_step(($serialized2 = $chash->serialize()) == '' ? -1 : 0);
test_step($serialized1 != $serialized2 ? -1 : 0);
test_end('');
test_start('serializeToFile');
@unlink(SERIALIZEPATH);
test_step(($size1 = $chash->serializeToFile(SERIALIZEPATH)) < 0 ? $size1 : 0);
test_end('serialized size is ' . $size1 . ' bytes');
$chash = new CHash();
test_start('unserializeFromFile');
test_step(($count = $chash->unserializeFromFile(SERIALIZEPATH)) < 0 ? $count : 0);
test_end('continuum count is ' . $count);
test_start('file serialize coherency');
test_step(($serialized2 = $chash->serialize()) == '' ? -1 : 0);