diff options
author | sanine <sanine.not@pm.me> | 2022-09-18 12:22:09 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2022-09-18 12:22:09 -0500 |
commit | 99672f4c2bdd1cddb4d749f8e82640db69f6ed08 (patch) | |
tree | b31d1ab956228a456c750df8b71591126642e3fd /src/import | |
parent | d444d1c98fdefea6cf0aff50eb9b58d4dbcea6ed (diff) |
add push_aistring
Diffstat (limited to 'src/import')
-rw-r--r-- | src/import/import.c | 6 | ||||
-rw-r--r-- | src/import/import.test.c | 17 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/import/import.c b/src/import/import.c index cc22616..cbd8d45 100644 --- a/src/import/import.c +++ b/src/import/import.c @@ -12,3 +12,9 @@ void push_vector(lua_State *L, struct aiVector3D vec) hs_str_num("z", vec.z), ); } + + +void push_aistring(lua_State *L, struct aiString str) +{ + lua_pushstring(L, str.data); +} diff --git a/src/import/import.test.c b/src/import/import.test.c index efa6b84..a234bda 100644 --- a/src/import/import.test.c +++ b/src/import/import.test.c @@ -1,3 +1,4 @@ +#include <string.h> #include <lua.h> #include <lauxlib.h> #include <honeysuckle.h> @@ -38,7 +39,23 @@ void test_push_vector() } +void test_push_aistring() +{ + lua_State *L = luaL_newstate(); + struct aiString str; + strcpy(str.data, "hello, world!"); + + push_aistring(L, str); + + lily_assert_int_equal(lua_type(L, -1), LUA_TSTRING); + lily_assert_string_equal((char*) lua_tostring(L, -1), "hello, world!"); + + lua_close(L); +} + + void suite_import() { lily_run_test(test_push_vector); + lily_run_test(test_push_aistring); } |