Small improvement to test functions.

This commit is contained in:
LoRd_MuldeR 2022-11-27 21:01:46 +01:00
parent 327f38d760
commit af8b940b56
3 changed files with 23 additions and 9 deletions

View File

@ -66,7 +66,8 @@ static INLINE uint64_t random_next(random_t *const rnd)
{\ {\
if (!hash_set_info64(hash_set, &capacity, &valid, &deleted, &limit)) \ 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) while(0)
@ -80,6 +81,7 @@ while(0)
static int test_function_1(hash_set64_t *const hash_set) static int test_function_1(hash_set64_t *const hash_set)
{ {
size_t capacity, valid, deleted, limit; size_t capacity, valid, deleted, limit;
uint8_t spinner = 0U;
for (size_t r = 0U; r < 5U; ++r) 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; return EXIT_FAILURE;
} }
} }
if (!(++spinner & 0x0F))
{
PRINT_SET_INFO(1); PRINT_SET_INFO(1);
} }
}
if (hash_set_size64(hash_set) != MAXIMUM - 4U) 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; return EXIT_FAILURE;
} }
} }
if (!(++spinner & 0x0F))
{
PRINT_SET_INFO(1); PRINT_SET_INFO(1);
} }
}
if (hash_set_size64(hash_set) != 1U) 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; size_t capacity, valid, deleted, limit;
uint64_t value; uint64_t value;
uint8_t test[ARRSIZE]; uint8_t test[ARRSIZE], spinner = 0U;
random_t random; random_t random;
random_init(&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); printf("Insert operation has failed! (error: %d)\n", error);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if (!(++spinner & 0x0F))
{
PRINT_SET_INFO(2); PRINT_SET_INFO(2);
} }
} }
}
while (!hash_set_iterate64(hash_set, &cursor, &value)) while (!hash_set_iterate64(hash_set, &cursor, &value))
{ {
if (!test[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); printf("Remove operation has failed! (error: %d)\n", error);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
PRINT_SET_INFO(2);
test[j] = UINT8_C(0); test[j] = UINT8_C(0);
if (!(++spinner & 0x0F))
{
PRINT_SET_INFO(2);
}
} }
} }
if (hash_set_size64(hash_set) != 0U) if (hash_set_size64(hash_set) != 0U)

View File

@ -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); size_t limit = round_sz(capacity * load_factor);