diff options
| author | Philipp Janda <siffiejoe@gmx.net> | 2017-08-27 10:16:23 +0200 |
|---|---|---|
| committer | Philipp Janda <siffiejoe@gmx.net> | 2017-08-27 10:16:23 +0200 |
| commit | 67aabb83a1eeea860b1a9a2104c90b80a523268a (patch) | |
| tree | d11498b47e25ebf2b0c9ffddd5f7c25bedc097a1 /tests/testmod.c | |
| parent | 3931e7fc37c5c3cc30f8e35e5bdb06a59af1e884 (diff) | |
| download | lua-compat-5.3-67aabb83a1eeea860b1a9a2104c90b80a523268a.tar.gz lua-compat-5.3-67aabb83a1eeea860b1a9a2104c90b80a523268a.tar.bz2 lua-compat-5.3-67aabb83a1eeea860b1a9a2104c90b80a523268a.zip | |
Handle edge case for lua_pushlstring(). Add test.
Diffstat (limited to 'tests/testmod.c')
| -rw-r--r-- | tests/testmod.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/testmod.c b/tests/testmod.c index 2293064..868136b 100644 --- a/tests/testmod.c +++ b/tests/testmod.c | |||
| @@ -246,6 +246,15 @@ static int test_tolstring (lua_State *L) { | |||
| 246 | return 2; | 246 | return 2; |
| 247 | } | 247 | } |
| 248 | 248 | ||
| 249 | static int test_pushstring (lua_State *L) { | ||
| 250 | lua_pushstring(L, lua_pushliteral(L, "abc")); | ||
| 251 | lua_pushstring(L, lua_pushlstring(L, "abc", 2)); | ||
| 252 | lua_pushstring(L, lua_pushlstring(L, NULL, 0)); | ||
| 253 | lua_pushstring(L, lua_pushstring(L, "abc")); | ||
| 254 | lua_pushboolean(L, NULL == lua_pushstring(L, NULL)); | ||
| 255 | return 10; | ||
| 256 | } | ||
| 257 | |||
| 249 | static int test_buffer (lua_State *L) { | 258 | static int test_buffer (lua_State *L) { |
| 250 | luaL_Buffer b; | 259 | luaL_Buffer b; |
| 251 | char *p = luaL_buffinitsize(L, &b, LUAL_BUFFERSIZE+1); | 260 | char *p = luaL_buffinitsize(L, &b, LUAL_BUFFERSIZE+1); |
| @@ -285,6 +294,7 @@ static const luaL_Reg funcs[] = { | |||
| 285 | { "uservalue", test_uservalue }, | 294 | { "uservalue", test_uservalue }, |
| 286 | { "globals", test_globals }, | 295 | { "globals", test_globals }, |
| 287 | { "tolstring", test_tolstring }, | 296 | { "tolstring", test_tolstring }, |
| 297 | { "pushstring", test_pushstring }, | ||
| 288 | { "buffer", test_buffer }, | 298 | { "buffer", test_buffer }, |
| 289 | { "exec", test_exec }, | 299 | { "exec", test_exec }, |
| 290 | { NULL, NULL } | 300 | { NULL, NULL } |
