aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-17 16:06:10 +0100
committerBenoit Giannangeli <giann@users.noreply.github.com>2017-03-20 07:49:26 +0100
commit9ac1d380dd1da894c6317845ea3234124663714b (patch)
treebc53f42224ba595eeba4fb66d5c648ec66ce2171 /tests
parent54a15b81c50a56c6cecbe99d597b95094427e3c6 (diff)
downloadfengari-9ac1d380dd1da894c6317845ea3234124663714b.tar.gz
fengari-9ac1d380dd1da894c6317845ea3234124663714b.tar.bz2
fengari-9ac1d380dd1da894c6317845ea3234124663714b.zip
string.pack/unpack/packsize test
Diffstat (limited to 'tests')
-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