use nix build & meson & zlog
This commit is contained in:
parent
0123623742
commit
346768a144
60 changed files with 13739 additions and 0 deletions
50
src/lib/testsuite/test_htab.c
Normal file
50
src/lib/testsuite/test_htab.c
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "unity.h"
|
||||
#include "htab.h"
|
||||
|
||||
static htab_t htab;
|
||||
static char *s = "Hello,world";
|
||||
|
||||
static void test_ht_add_string(void) {
|
||||
hent_t *e = NULL;
|
||||
|
||||
e = ht_add(&(htab), (void *)s);
|
||||
TEST_ASSERT_NOT_NULL(e);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void test_ht_get_string(void) {
|
||||
hent_t *e = NULL;
|
||||
|
||||
e = ht_get(&htab, (void *)s);
|
||||
TEST_ASSERT_NOT_NULL(e);
|
||||
|
||||
TEST_ASSERT_TRUE(0 == strcmp(e->key, s));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void test_ht_del_string(void) {
|
||||
hent_t *e = NULL;
|
||||
|
||||
ht_del(&htab, (void *)s);
|
||||
|
||||
e = ht_get(&htab, (void *)s);
|
||||
TEST_ASSERT_TRUE( e == NULL);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void test_ht_string(void) {
|
||||
printf("\n>> htab test string\n\n");
|
||||
|
||||
ht_init(&htab, 13, string_hash_key);
|
||||
|
||||
RUN_TEST(test_ht_add_string);
|
||||
RUN_TEST(test_ht_get_string);
|
||||
RUN_TEST(test_ht_del_string);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue