Small improvement to test functions.
This commit is contained in:
parent
327f38d760
commit
af8b940b56
@ -66,7 +66,8 @@ static INLINE uint64_t random_next(random_t *const rnd)
|
||||
{\
|
||||
if (!hash_set_info64(hash_set, &capacity, &valid, &deleted, &limit)) \
|
||||
{ \
|
||||
printf("[#%d] capacity: %010zu, valid: %010zu, deleted: %010zu, limit: %010zu\n", (X), capacity, valid, deleted, limit); \
|
||||
fprintf(stdout, "[#%d] capacity: %010zu, valid: %010zu, deleted: %010zu, limit: %010zu\n", (X), capacity, valid, deleted, limit); \
|
||||
fflush(stdout); \
|
||||
} \
|
||||
} \
|
||||
while(0)
|
||||
@ -80,6 +81,7 @@ while(0)
|
||||
static int test_function_1(hash_set64_t *const hash_set)
|
||||
{
|
||||
size_t capacity, valid, deleted, limit;
|
||||
uint8_t spinner = 0U;
|
||||
|
||||
for (size_t r = 0U; r < 5U; ++r)
|
||||
{
|
||||
@ -94,8 +96,11 @@ static int test_function_1(hash_set64_t *const hash_set)
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
if (!(++spinner & 0x0F))
|
||||
{
|
||||
PRINT_SET_INFO(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (hash_set_size64(hash_set) != MAXIMUM - 4U)
|
||||
{
|
||||
@ -143,8 +148,11 @@ static int test_function_1(hash_set64_t *const hash_set)
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
if (!(++spinner & 0x0F))
|
||||
{
|
||||
PRINT_SET_INFO(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (hash_set_size64(hash_set) != 1U)
|
||||
{
|
||||
@ -197,7 +205,7 @@ static int test_function_2(hash_set64_t *const hash_set)
|
||||
{
|
||||
size_t capacity, valid, deleted, limit;
|
||||
uint64_t value;
|
||||
uint8_t test[ARRSIZE];
|
||||
uint8_t test[ARRSIZE], spinner = 0U;
|
||||
|
||||
random_t random;
|
||||
random_init(&random);
|
||||
@ -227,9 +235,12 @@ static int test_function_2(hash_set64_t *const hash_set)
|
||||
printf("Insert operation has failed! (error: %d)\n", error);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (!(++spinner & 0x0F))
|
||||
{
|
||||
PRINT_SET_INFO(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
while (!hash_set_iterate64(hash_set, &cursor, &value))
|
||||
{
|
||||
if (!test[value])
|
||||
@ -248,8 +259,11 @@ static int test_function_2(hash_set64_t *const hash_set)
|
||||
printf("Remove operation has failed! (error: %d)\n", error);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
PRINT_SET_INFO(2);
|
||||
test[j] = UINT8_C(0);
|
||||
if (!(++spinner & 0x0F))
|
||||
{
|
||||
PRINT_SET_INFO(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hash_set_size64(hash_set) != 0U)
|
||||
|
@ -41,7 +41,7 @@ typedef struct _hash_set32 hash_set32_t;
|
||||
typedef struct _hash_set64 hash_set64_t;
|
||||
|
||||
HASHSET_API hash_set32_t *hash_set_create32(const size_t initial_capacity, const double load_factor);
|
||||
HASHSET_API hash_set64_t* hash_set_create64(const size_t initial_capacity, const double load_factor);
|
||||
HASHSET_API hash_set64_t *hash_set_create64(const size_t initial_capacity, const double load_factor);
|
||||
|
||||
HASHSET_API void hash_set_destroy32(hash_set32_t *const instance);
|
||||
HASHSET_API void hash_set_destroy64(hash_set64_t *const instance);
|
||||
|
@ -163,7 +163,7 @@ static INLINE void put_value(struct DATA_STRUCT *const data, const size_t index,
|
||||
}
|
||||
}
|
||||
|
||||
static size_t INLINE compute_limit(const size_t capacity, const double load_factor)
|
||||
static INLINE size_t compute_limit(const size_t capacity, const double load_factor)
|
||||
{
|
||||
size_t limit = round_sz(capacity * load_factor);
|
||||
|
||||
@ -216,7 +216,7 @@ static INLINE errno_t rebuild_set(hash_set_t *const instance, const size_t new_c
|
||||
/* PUBLIC FUNCTIONS */
|
||||
/* ========================================================================= */
|
||||
|
||||
hash_set_t* MAKE_NAME(hash_set_create)(const size_t initial_capacity, const double load_factor)
|
||||
hash_set_t *MAKE_NAME(hash_set_create)(const size_t initial_capacity, const double load_factor)
|
||||
{
|
||||
hash_set_t* instance = (hash_set_t*) calloc(1U, sizeof(hash_set_t));
|
||||
if (!instance)
|
||||
|
Loading…
Reference in New Issue
Block a user