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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user