dhash_test.c revision 4fdcab8ba579b481870d5a6a422fcca70712d30f
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <getopt.h>
#include "dhash.h"
#define DEFAULT_MAX_TEST (500)
unsigned long max_test = DEFAULT_MAX_TEST;
int verbose = 0;
const char *error_string(int error)
{
if (IS_HASH_ERROR(error))
return hash_error_string(error);
}
{
static char buf[1024];
case HASH_KEY_ULONG:
break;
case HASH_KEY_STRING:
break;
default:
break;
}
return buf;
}
{
static char buf[1024];
case HASH_VALUE_UNDEF:
break;
case HASH_VALUE_PTR:
break;
case HASH_VALUE_INT:
break;
case HASH_VALUE_UINT:
break;
case HASH_VALUE_LONG:
break;
case HASH_VALUE_ULONG:
break;
case HASH_VALUE_FLOAT:
break;
case HASH_VALUE_DOUBLE:
break;
default:
break;
}
return buf;
}
{
static char buf[1024];
return buf;
}
{
unsigned long *callback_count = (unsigned long *)user_data;
(*callback_count)++;
return true;
}
{
}
typedef struct test_val_t {
long val;
char *str;
} test_val_t;
{
long i, k;
int status;
char buf[1024];
unsigned long callback_count = 0;
unsigned int directory_bits = HASH_DEFAULT_DIRECTORY_BITS;
unsigned int segment_bits = HASH_DEFAULT_SEGMENT_BITS;
unsigned long min_load_factor = HASH_DEFAULT_MIN_LOAD_FACTOR;
unsigned long max_load_factor = HASH_DEFAULT_MAX_LOAD_FACTOR;
while (1) {
int arg;
int option_index = 0;
static struct option long_options[] = {
{"count", 1, 0, 'c'},
{"verbose", 1, 0, 'v'},
{"quiet", 1, 0, 'q'},
{"directory-bits", 1, 0, 'd'},
{"segment-bits", 1, 0, 's'},
{"min-load-factor", 1, 0, 'l'},
{"max-load-factor", 1, 0, 'h'},
{0, 0, 0, 0}
};
if (arg == -1) break;
switch (arg) {
case 'c':
break;
case 'v':
verbose = 1;
break;
case 'q':
verbose = 0;
break;
case 'd':
break;
case 's':
break;
case 'l':
break;
case 'h':
break;
}
}
exit(1);
}
exit(1);
}
exit(1);
}
/* Initialize the random number generator */
/* Create the hash table as small as possible to exercise growth */
exit(1);
}
/* Initialize the array of test values */
for (i = 0; i < max_test; i++) {
/* If the value is odd we'll use a string as the key,
* otherwise we'll use an unsigned long as the key */
}
}
/* Enter all the test values into the hash table */
for (i = 0; i < max_test; i++) {
}
else {
}
exit(1);
}
exit(1);
}
}
/* Now visit each entry in the table using a callback iterator,
* store what we found in iter_result_1 for testing the iterator object later on */
callback_count = 0;
exit(1);
}
exit(1);
}
/* Now vist each entry in the table using an iterator object */
{
struct hash_iter_context_t *iter;
unsigned long n_items;
n_items = 0;
n_items++;
}
exit(1);
}
}
/* Both iterators should have visited each item in the same order, verify ... */
for (i = 0; i < max_test; i++) {
i, i, __LINE__);
exit(1);
}
}
/* Get an array of keys in the table, print them out */
{
unsigned long count;
exit(1);
}
exit(1);
}
for (i = 0; i < count; i++) {
}
}
/* Get an array of values in the table, print them out */
{
unsigned long count;
exit(1);
}
for (i = 0; i < count; i++) {
}
}
/* Get an array of items in the table, print them out */
{
unsigned long count;
exit(1);
}
for (i = 0; i < count; i++) {
}
}
/* See if we can find every key */
for (i = max_test - 1; i >= 0; i--) {
}
else {
}
exit(1);
}
else {
case HASH_VALUE_PTR:
exit(1);
}
break;
case HASH_VALUE_LONG:
exit(1);
}
break;
default:
break;
}
}
}
/*
* Delete a key, make sure we can't find it, assure we can find all other
* keys.
*/
for (i = 0; i < max_test; i++) {
}
else {
}
exit(1);
}
exit(1);
}
exit(1);
}
/* See if we can find all remaining keys */
for (k = i + 1; k < max_test; k++) {
} else {
}
exit(1);
} else {
case HASH_VALUE_PTR:
exit(1);
}
break;
case HASH_VALUE_LONG:
exit(1);
}
break;
default:
break;
}
}
}
}
#ifdef HASH_STATISTICS
{
exit(1);
}
printf("Statistics: Accesses = %ld, Collisions = %ld, Collision Rate = %.2f, Expansions = %ld, Contractions = %ld\n",
}
#endif
exit(1);
}
for (i = 0; i < max_test; i++) {
}
}
return 0;
}