summaryrefslogtreecommitdiff
path: root/tests/lstrlib.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-17 16:06:10 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-20 07:42:37 +0100
commit6d684333cbbf92ce940b0f10b126197bb2e04b93 (patch)
treebc53f42224ba595eeba4fb66d5c648ec66ce2171 /tests/lstrlib.js
parentaea4af6bafafd0aa166e41ead5ce90b530e3ac0a (diff)
downloadfengari-6d684333cbbf92ce940b0f10b126197bb2e04b93.tar.gz
fengari-6d684333cbbf92ce940b0f10b126197bb2e04b93.tar.bz2
fengari-6d684333cbbf92ce940b0f10b126197bb2e04b93.zip
string.pack/unpack/packsize test
Diffstat (limited to 'tests/lstrlib.js')
-rw-r--r--tests/lstrlib.js17
1 files changed, 11 insertions, 6 deletions
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