1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-12-10 17:35:18 +01:00

Backport PUC Lua 5.4's string.{pack,unpack,packsize}

This commit is contained in:
Lars Müller
2025-12-08 23:19:24 +01:00
committed by GitHub
parent 98c6f786f8
commit 6daf3871e7
9 changed files with 568 additions and 0 deletions

View File

@@ -363,3 +363,11 @@ local function test_sandbox()
assert(debug.getinfo(function() end, "f").func ~= nil)
end
unittests.register("test_sandbox", test_sandbox)
local function test_str_pack_unpack()
local fmt = "> d!2 xh"
assert(fmt:packsize() == 12) -- 8 double, 1 padding, 1 implicit align, 2 short
local a, b = fmt:unpack(fmt:pack(42.3, -384))
assert(a == 42.3 and b == -384)
end
unittests.register("test_str_pack_unpack", test_str_pack_unpack)