From 6d684333cbbf92ce940b0f10b126197bb2e04b93 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Fri, 17 Mar 2017 16:06:10 +0100 Subject: string.pack/unpack/packsize test --- tests/lstrlib.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/lstrlib.js b/tests/lstrlib.js index 4185f04..6364c7f 100644 --- a/tests/lstrlib.js +++ b/tests/lstrlib.js @@ -465,12 +465,12 @@ test('string.dump', function (t) { test('string.pack/unpack/packsize', function (t) { let luaCode = ` local s1, n, s2 = "hello", 2, "you" - local packed = string.pack("zjz", s1, n, s2) - local us1, un, us2 = string.unpack("zjz", packed) - return s1 == us1 and n == un and s2 == us2 + local packed = string.pack("c5jc3", s1, n, s2) + local us1, un, us2 = string.unpack("c5jc3", packed) + return string.packsize("c5jc3"), s1 == us1 and n == un and s2 == us2 `, L; - t.plan(3); + t.plan(4); t.doesNotThrow(function () { @@ -489,8 +489,13 @@ test('string.pack/unpack/packsize', function (t) { }, "Lua program ran without error"); t.strictEqual( - lapi.lua_tostring(L, -1), - "FFFFFFF", + lapi.lua_tointeger(L, -2), + 16, + "Correct element(s) on the stack" + ); + + t.ok( + lapi.lua_toboolean(L, -1), "Correct element(s) on the stack" ); }); \ No newline at end of file -- cgit v1.2.3-70-g09d2