Skip to content

Commit f529ee9

Browse files
committed
tests/lapi: fix string_pack_test
The function `string.pack()` raises, the patch wraps it by `xpcall()` and suppress errors with message "invalid format option". Follows up #124
1 parent 41cd3d1 commit f529ee9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tests/lapi/string_pack_test.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ if not test_lib.lua_current_version_ge_than(5, 3) then
1717
os.exit(0)
1818
end
1919

20+
local ignored_msgs = {
21+
"invalid format option",
22+
}
23+
2024
local function TestOneInput(buf, _size)
2125
local fdp = luzer.FuzzedDataProvider(buf)
2226
os.setlocale(test_lib.random_locale(fdp), "all")
@@ -26,7 +30,10 @@ local function TestOneInput(buf, _size)
2630
end
2731
local n = fdp:consume_integer(1, test_lib.MAX_INT)
2832
local values = fdp:consume_strings(test_lib.MAX_STR_LEN, n)
29-
string.pack(fmt_str, table.unpack(values))
33+
local err_handler = test_lib.err_handler(ignored_msgs)
34+
local ok, _ = xpcall(string.pack, err_handler, fmt_str,
35+
table.unpack(values))
36+
if not ok then return end
3037
end
3138

3239
local args = {

0 commit comments

Comments
 (0)