1
0
Fork 0
hash-table/src/main.c

33 lines
1.0 KiB
C
Raw Normal View History

2024-04-13 12:16:20 +00:00
#include "base.h"
#include "arena.h"
#include "string.h"
#include "hash-store.h"
#include "arena.c"
#include "string.c"
#include "hash-store.c"
2024-04-12 15:26:08 +00:00
int
main(void)
{
2024-04-13 12:16:20 +00:00
Table store = hash_store_initialize();
Key a = hash_store_string8_to_key(&store, str8_lit("Hello"));
Key b = hash_store_string8_to_key(&store, str8_lit("Beautiful"));
Key c = hash_store_string8_to_key(&store, str8_lit("World"));
String8 str_a = hash_store_string8_from_key(&store, a);
String8 str_b = hash_store_string8_from_key(&store, b);
String8 str_c = hash_store_string8_from_key(&store, c);
ASSERT(hash_store_string8_to_key(&store, str8_lit("Hello")) == a);
ASSERT(hash_store_string8_to_key(&store, str8_lit("Beautiful")) == b);
ASSERT(hash_store_string8_to_key(&store, str8_lit("World")) == c);
ASSERT(string8_match(hash_store_string8_from_key(&store, a), str8_lit("Hello")));
ASSERT(string8_match(hash_store_string8_from_key(&store, b), str8_lit("Beautiful")));
ASSERT(string8_match(hash_store_string8_from_key(&store, c), str8_lit("World")));
2024-04-12 15:26:08 +00:00
return 0;
};