summaryrefslogtreecommitdiff
path: root/src/util/util.test.c
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2022-08-22 21:37:12 -0500
committersanine <sanine.not@pm.me>2022-08-22 21:37:12 -0500
commit1f75a21851b0a0bd4bc766c458e67721dd37c9fd (patch)
tree498b9f43176f098c852099707e5eb1717bcd1ec1 /src/util/util.test.c
parent1f47b685f35455afcc7441389cdc60018f66d159 (diff)
add append_table()
Diffstat (limited to 'src/util/util.test.c')
-rw-r--r--src/util/util.test.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/util/util.test.c b/src/util/util.test.c
new file mode 100644
index 0000000..b4029d2
--- /dev/null
+++ b/src/util/util.test.c
@@ -0,0 +1,47 @@
+#include <lua.h>
+#include <lauxlib.h>
+#include <honeysuckle.h>
+#include "test/honey-test.h"
+
+
+#include "util.c"
+
+
+void test_append_table()
+{
+ lua_State *L = luaL_newstate();
+ int a = hs_create_table(L,
+ hs_str_int("one", 1),
+ hs_str_int("two", 2),
+ );
+ int b = hs_create_table(L,
+ hs_str_int("three", 3),
+ hs_str_int("four", 4),
+ hs_int_int(15, 2),
+ );
+ append_table(L, a, b);
+
+ lua_getfield(L, a, "one");
+ lily_assert_int_equal(lua_tointeger(L, -1), 1);
+
+ lua_getfield(L, a, "two");
+ lily_assert_int_equal(lua_tointeger(L, -1), 2);
+
+ lua_getfield(L, a, "three");
+ lily_assert_int_equal(lua_tointeger(L, -1), 3);
+
+ lua_getfield(L, a, "four");
+ lily_assert_int_equal(lua_tointeger(L, -1), 4);
+
+ lua_pushinteger(L, 15);
+ lua_gettable(L, a);
+ lily_assert_int_equal(lua_tointeger(L, -1), 2);
+
+ lua_close(L);
+}
+
+
+void suite_util()
+{
+ lily_run_test(test_append_table);
+}