test_end('added ' . $chash->getTargetsCount() . ' targets'); test_start('removeTarget'); for ($index = 10; $index < 30; $index++) { test_step($chash->removeTarget(sprintf('target%03d', $index))); } test_step($chash->getTargetsCount() == TARGETS - 20 ? 0 : -1, 'invalid targets count ' . $chash->getTargetsCount()); test_end('targets count is now ' . $chash->getTargetsCount()); 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);