37 lines
895 B
C
37 lines
895 B
C
#include "haggis.h"
|
|
#include "haggis_private.h"
|
|
#include <assert.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/types.h>
|
|
|
|
int main() {
|
|
hmap *map;
|
|
struct stat st;
|
|
char *data;
|
|
union {
|
|
ino_t val;
|
|
u8 bytes[sizeof(ino_t)];
|
|
} nod;
|
|
char * ret = NULL;
|
|
|
|
map = hmap_init(sizeof(ino_t));
|
|
assert(map != NULL);
|
|
data = "Makefile";
|
|
stat(data, &st);
|
|
nod.val = st.st_ino;
|
|
ret = hmap_insert(map, &nod.bytes[0], data);
|
|
assert(ret == NULL);
|
|
assert(map->len == 1);
|
|
ret = hmap_get(map, &nod.bytes[0]);
|
|
assert(memcmp(ret, data, 7) == 0);
|
|
ret = hmap_insert(map, &nod.bytes[0], "testdata");
|
|
assert(ret != NULL);
|
|
assert(memcmp(ret, data, 8) == 0);
|
|
assert(map->len == 1);
|
|
ret = hmap_get(map, &nod.bytes[0]);
|
|
assert(memcmp(ret, "testdata", 9) == 0);
|
|
hmap_deinit(map);
|
|
return 0;
|
|
}
|