56 lines
920 B
C
56 lines
920 B
C
#include <stdint.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <unity/unity.h>
|
|
|
|
#include "htab.h"
|
|
|
|
static htab_t htab;
|
|
|
|
uint64_t key = (uint64_t)0xfabcde6666666666;
|
|
|
|
static void test_ht_add_string(void)
|
|
{
|
|
hent_t* e = NULL;
|
|
|
|
e = ht_add(&(htab), (void*)key);
|
|
TEST_ASSERT_NOT_NULL(e);
|
|
|
|
return;
|
|
}
|
|
|
|
static void test_ht_get_string(void)
|
|
{
|
|
hent_t* e = NULL;
|
|
|
|
e = ht_get(&htab, (void*)key);
|
|
TEST_ASSERT_NOT_NULL(e);
|
|
|
|
TEST_ASSERT_TRUE((uint64_t)e->key == (uint64_t)key);
|
|
|
|
return;
|
|
}
|
|
|
|
static void test_ht_del_string(void)
|
|
{
|
|
hent_t* e = NULL;
|
|
|
|
ht_del(&htab, (void*)key);
|
|
|
|
e = ht_get(&htab, (void*)key);
|
|
TEST_ASSERT_TRUE(e == NULL);
|
|
|
|
return;
|
|
}
|
|
|
|
void test_ht_int(void)
|
|
{
|
|
printf("\n>> htab test int\n\n");
|
|
|
|
ht_init(&htab, 13, int_hash_key);
|
|
|
|
RUN_TEST(test_ht_add_string);
|
|
RUN_TEST(test_ht_get_string);
|
|
RUN_TEST(test_ht_del_string);
|
|
}
|