From c1d23a00b80b4d20df1b4048aa60e85263a45ded Mon Sep 17 00:00:00 2001 From: Andre Wagner Date: Wed, 13 May 2026 17:58:54 -0500 Subject: [PATCH] . --- test/tests.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/tests.c b/test/tests.c index cfff416..24ea6a6 100644 --- a/test/tests.c +++ b/test/tests.c @@ -134,6 +134,33 @@ int main() heap_destroy(h); } + { + printf("### Table - string index\n"); + + Heap* h = heap_new(); + Table* t = table_new(h); + + VALUE key1 = create_value_idx(TT_STRING, heap_add_string(h, "key1")); + VALUE key2 = create_value_idx(TT_STRING, heap_add_string(h, "key2")); + + table_set(t, key1, create_value_integer(100)); + table_set(t, key2, create_value_integer(200)); + + VALUE key1b = create_value_idx(TT_STRING, heap_add_string(h, "key1")); + VALUE key2b = create_value_idx(TT_STRING, heap_add_string(h, "key2")); + + VALUE v; + assert(table_get(t, key1b, &v) == T_OK); assert(value_integer(v) == 100); + assert(table_get(t, key2b, &v) == T_OK); assert(value_integer(v) == 200); + + table_del(t, key2b); + assert(table_get(t, key1b, &v) == T_OK); + assert(table_get(t, key2b, &v) == T_ERR_TABLE_KEY_NOT_FOUND); + + table_destroy(t); + heap_destroy(h); + } + { printf("### Heap - strings\n");