From a378ff1b173f7a67272e574fb1a2c275ecb9661b Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Mon, 21 Jul 2025 11:59:06 +0200 Subject: test: rewrite tests --- test_json.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'test_json.c') diff --git a/test_json.c b/test_json.c index b0f1028..751b5bd 100644 --- a/test_json.c +++ b/test_json.c @@ -37,13 +37,15 @@ char test_json_int_array() { char test_json_nested_array() { Arena perm = Arena_new(128e3); - JSON jaa = JSON_parse(&perm, "[[1,\"abc\"]]"); - - JSON sub_array = *Vec_get(jaa.array, JSON, 0); - JSON *val_1 = Vec_get(sub_array.array, JSON, 0); - t_assert(*val_1->integer == 1); - JSON *val_2 = Vec_get(sub_array.array, JSON, 1); - t_assert(Str_equals(*val_2->string, S("abc"))); + JSON doc = JSON_parse(&perm, "[[1,\"abc\"]]"); + + JSON sub_array = *Vec_get(doc.array, JSON, 0); + JSON val_1 = *Vec_get(sub_array.array, JSON, 0); + t_assert(*val_1.integer == 1); + JSON val_2 = *Vec_get(sub_array.array, JSON, 1); + Str str = *val_2.string; + Str expected = S("abc"); + t_assert(Str_equals(str, expected)); t_assert(Arena_get_used(perm) == 203); return 0; @@ -54,7 +56,7 @@ char test_json_string() { JSON js = JSON_parse(&perm, "\"abc\""); - t_assert(Str_equals(*js.string, S("abc")) == 1); + t_assert(Str_equals(*js.string, S("abc"))); t_assert(Arena_get_used(perm) == 27); return 0; -- cgit v1.3