From 574c0905c1ab394b20e4a763d0f85c042c3cd45b Mon Sep 17 00:00:00 2001 From: Philipp Janda Date: Wed, 9 Aug 2017 23:07:31 +0200 Subject: Add tests for luaL_tolstring and string.pack. --- tests/test.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/test.lua b/tests/test.lua index 8adad1a..be16af9 100755 --- a/tests/test.lua +++ b/tests/test.lua @@ -282,8 +282,9 @@ end if string.pack then - -- TODO - print("TODO: test string packing/unpacking") + local format = "bBhHlLjJdc3z" + local s = string.pack(format, -128, 255, -32768, 65535, -2147483648, 4294967295, -32768, 65536, 1.25, "abc", "defgh") + print("string.unpack", string.unpack(format, s)) ___'' else print("XXX: string packing not available") @@ -770,6 +771,9 @@ local t = setmetatable({}, { __tostring = function(v) return nil end }) print(pcall(mod.tolstring, t)) +local ud, meta = mod.newproxy() +meta.__name = "XXX" +print(mod.tolstring(ud):gsub(":.*$", ": yyy")) ___'' print(mod.buffer()) -- cgit v1.2.3-55-g6feb