1
0
Fork 0

Added: test setup for hash storage

Browse Source
This commit is contained in:
rhuibertsjr 2024-04-13 14:16:20 +02:00
parent 1faad172e9
commit cfa7370f07
2 changed files with 28 additions and 1 deletions

View File

@ -6,6 +6,6 @@ if not exist ".\build" mkdir ".\build"
pushd .\build pushd .\build
cl /Zi ..\src\main.c /Feapp.exe /Od /nologo /I..\src cl /Zi ..\src\main.c /Feapp.exe /Od /nologo
popd .\build popd .\build

View File

@ -1,5 +1,32 @@
#include "base.h"
#include "arena.h"
#include "string.h"
#include "hash-store.h"
#include "arena.c"
#include "string.c"
#include "hash-store.c"
int int
main(void) main(void)
{ {
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")));
return 0; return 0;
}; };