Mercurial
diff dowa/dowa_test.c @ 264:04fee26ecce0
add authenticated JRPG conversation platform
Add reusable auth/session storage, owned conversation recovery, guest quotas, admin workflows, URL-routed conversation UI, mobile frame support, and parallel browser acceptance.
Co-authored-by: Copilot <[email protected]>
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Fri, 07 Aug 2026 07:34:12 -0700 |
| parents | 1f9877b637e9 |
| children |
line wrap: on
line diff
--- a/dowa/dowa_test.c Thu Aug 06 11:31:30 2026 -0700 +++ b/dowa/dowa_test.c Fri Aug 07 07:34:12 2026 -0700 @@ -347,6 +347,47 @@ printf("randon_number 2: %i\n", random_number2); } + /* --- Malformed JSON regression tests --- */ + { + Dowa_Arena *a = Dowa_Arena_Create(1024); + const char *s = "{\"username\":[x]}"; + Dowa_JSON_Value v = Dowa_JSON_Parse(s, (int32)strlen(s), a); + assert(v.type == DOWA_JSON_OBJECT); + Dowa_JSON_Value *uv = Dowa_JSON_Get(v.object_val, "username"); + assert(uv && uv->type == DOWA_JSON_ARRAY); + Dowa_Arena_Free(a); + } + { + Dowa_Arena *a = Dowa_Arena_Create(1024); + const char *s = "xyz"; + Dowa_JSON_Value v = Dowa_JSON_Parse(s, (int32)strlen(s), a); + assert(v.type == DOWA_JSON_NULL); + Dowa_Arena_Free(a); + } + { + Dowa_Arena *a = Dowa_Arena_Create(1024); + const char *s = "[x, y, z]"; + Dowa_JSON_Value v = Dowa_JSON_Parse(s, (int32)strlen(s), a); + assert(v.type == DOWA_JSON_ARRAY); + Dowa_Arena_Free(a); + } + { + Dowa_Arena *a = Dowa_Arena_Create(1024); + const char *s = "{\"a\":x,\"b\":\"ok\"}"; + Dowa_JSON_Value v = Dowa_JSON_Parse(s, (int32)strlen(s), a); + assert(v.type == DOWA_JSON_OBJECT); + char *b = Dowa_JSON_Get_String(v.object_val, "b"); + assert(b && strcmp(b, "ok") == 0); + Dowa_Arena_Free(a); + } + { + Dowa_Arena *a = Dowa_Arena_Create(1024); + const char *s = "{\"a\":\"unclosed"; + Dowa_JSON_Value v = Dowa_JSON_Parse(s, (int32)strlen(s), a); + assert(v.type == DOWA_JSON_OBJECT); + Dowa_Arena_Free(a); + } + printf("=== All tests passed! ===\n"); return 0; }