Esempio n. 1
0
    }
    if (!$test_status && $test_message == '' && $message != '') {
        $test_message = $message;
    }
    if ($test_message != '') {
        print ' - ' . $test_message;
    }
    print ")\n";
}
$chash = new CHash();
$chash->useExceptions(false);
// Execute tests
print "\n";
test_start('addTarget');
for ($index = 1; $index <= TARGETS; $index++) {
    test_step($chash->addTarget(sprintf('target%03d', $index)));
}
test_step($chash->getTargetsCount() == TARGETS ? 0 : -1, 'invalid targets count ' . $chash->getTargetsCount());
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++) {