Mercurial
diff dowa/dowa_test.c @ 87:d39e8860a361
[Dowa] There was alignment issues rea
hash key
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Thu, 01 Jan 2026 14:25:17 -0800 |
| parents | 4532ce6d9eb8 |
| children | 655ea0b661fd |
line wrap: on
line diff
--- a/dowa/dowa_test.c Thu Jan 01 14:05:34 2026 -0800 +++ b/dowa/dowa_test.c Thu Jan 01 14:25:17 2026 -0800 @@ -212,6 +212,58 @@ Dowa_HashMap_Free(p_large_map); printf(" Medium map freed\n\n"); + // --- Test Key Storage Integrity --- + printf("Testing Key Storage Integrity (Regression Test)...\n"); + Dowa_KV(char*, char*)* p_integrity_map = NULL; + + // Simple test first + Dowa_HashMap_Push(p_integrity_map, "HTTP_Method", "GET"); + Dowa_HashMap_Push(p_integrity_map, "Path", "/index.html"); + + printf(" Testing simple 2-key map...\n"); + void* p_method = Dowa_HashMap_Get_Ptr(p_integrity_map, "HTTP_Method"); + void* p_path = Dowa_HashMap_Get_Ptr(p_integrity_map, "Path"); + + if (p_method && p_path) + { + Dowa_KV(char*, char*)* p_m = (Dowa_KV(char*, char*)*)p_method; + Dowa_KV(char*, char*)* p_p = (Dowa_KV(char*, char*)*)p_path; + printf(" Method: key='%s', value='%s'\n", p_m->key, p_m->value); + printf(" Path: key='%s', value='%s'\n", p_p->key, p_p->value); + printf(" PASS: Simple test passed\n"); + } + else + { + printf(" FAIL: Could not find keys\n"); + } + + Dowa_HashMap_Free(p_integrity_map); + p_integrity_map = NULL; + + // Test with arena allocator + printf(" Testing arena-allocated map...\n"); + Dowa_Arena *p_integrity_arena = Dowa_Arena_Create(4096); + Dowa_HashMap_Push_Arena(p_integrity_map, "HTTP_Method", "POST", p_integrity_arena); + Dowa_HashMap_Push_Arena(p_integrity_map, "Content-Type", "application/json", p_integrity_arena); + + p_method = Dowa_HashMap_Get_Ptr(p_integrity_map, "HTTP_Method"); + void* p_content_type = Dowa_HashMap_Get_Ptr(p_integrity_map, "Content-Type"); + + if (p_method && p_content_type) + { + Dowa_KV(char*, char*)* p_m = (Dowa_KV(char*, char*)*)p_method; + Dowa_KV(char*, char*)* p_ct = (Dowa_KV(char*, char*)*)p_content_type; + printf(" Method: key='%s', value='%s'\n", p_m->key, p_m->value); + printf(" Content-Type: key='%s', value='%s'\n", p_ct->key, p_ct->value); + printf(" PASS: Arena test passed\n"); + } + else + { + printf(" FAIL: Could not find keys\n"); + } + + Dowa_Arena_Free(p_integrity_arena); + printf(" Key integrity test complete\n\n"); printf("=== String Manipulations === \n\n");