comparison 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
comparison
equal deleted inserted replaced
86:431df06b1a9b 87:d39e8860a361
210 printf(" Has key 'key_99': %d\n", has_99); 210 printf(" Has key 'key_99': %d\n", has_99);
211 211
212 Dowa_HashMap_Free(p_large_map); 212 Dowa_HashMap_Free(p_large_map);
213 printf(" Medium map freed\n\n"); 213 printf(" Medium map freed\n\n");
214 214
215 // --- Test Key Storage Integrity ---
216 printf("Testing Key Storage Integrity (Regression Test)...\n");
217 Dowa_KV(char*, char*)* p_integrity_map = NULL;
218
219 // Simple test first
220 Dowa_HashMap_Push(p_integrity_map, "HTTP_Method", "GET");
221 Dowa_HashMap_Push(p_integrity_map, "Path", "/index.html");
222
223 printf(" Testing simple 2-key map...\n");
224 void* p_method = Dowa_HashMap_Get_Ptr(p_integrity_map, "HTTP_Method");
225 void* p_path = Dowa_HashMap_Get_Ptr(p_integrity_map, "Path");
226
227 if (p_method && p_path)
228 {
229 Dowa_KV(char*, char*)* p_m = (Dowa_KV(char*, char*)*)p_method;
230 Dowa_KV(char*, char*)* p_p = (Dowa_KV(char*, char*)*)p_path;
231 printf(" Method: key='%s', value='%s'\n", p_m->key, p_m->value);
232 printf(" Path: key='%s', value='%s'\n", p_p->key, p_p->value);
233 printf(" PASS: Simple test passed\n");
234 }
235 else
236 {
237 printf(" FAIL: Could not find keys\n");
238 }
239
240 Dowa_HashMap_Free(p_integrity_map);
241 p_integrity_map = NULL;
242
243 // Test with arena allocator
244 printf(" Testing arena-allocated map...\n");
245 Dowa_Arena *p_integrity_arena = Dowa_Arena_Create(4096);
246 Dowa_HashMap_Push_Arena(p_integrity_map, "HTTP_Method", "POST", p_integrity_arena);
247 Dowa_HashMap_Push_Arena(p_integrity_map, "Content-Type", "application/json", p_integrity_arena);
248
249 p_method = Dowa_HashMap_Get_Ptr(p_integrity_map, "HTTP_Method");
250 void* p_content_type = Dowa_HashMap_Get_Ptr(p_integrity_map, "Content-Type");
251
252 if (p_method && p_content_type)
253 {
254 Dowa_KV(char*, char*)* p_m = (Dowa_KV(char*, char*)*)p_method;
255 Dowa_KV(char*, char*)* p_ct = (Dowa_KV(char*, char*)*)p_content_type;
256 printf(" Method: key='%s', value='%s'\n", p_m->key, p_m->value);
257 printf(" Content-Type: key='%s', value='%s'\n", p_ct->key, p_ct->value);
258 printf(" PASS: Arena test passed\n");
259 }
260 else
261 {
262 printf(" FAIL: Could not find keys\n");
263 }
264
265 Dowa_Arena_Free(p_integrity_arena);
266 printf(" Key integrity test complete\n\n");
215 267
216 printf("=== String Manipulations === \n\n"); 268 printf("=== String Manipulations === \n\n");
217 269
218 printf(" Split strings without arena \n\n"); 270 printf(" Split strings without arena \n\n");
219 { 271 {