Skip to content

Commit 3ee6fcd

Browse files
committed
tests/lapi: fix utf8_offset_test
The function `utf8.offset()` raises, the patch wraps it by `xpcall()` and suppress errors with message "initial position is a continuation byte". Follows up #143
1 parent f529ee9 commit 3ee6fcd

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tests/lapi/utf8_offset_test.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,20 @@ if test_lib.lua_current_version_lt_than(5, 3) then
1919
os.exit()
2020
end
2121

22+
local ignored_msgs = {
23+
"initial position is a continuation byte",
24+
}
25+
2226
local function TestOneInput(buf)
2327
local fdp = luzer.FuzzedDataProvider(buf)
2428
local max_len = fdp:consume_integer(0, MAX_INT)
2529
local s = fdp:consume_string(max_len)
2630
local n = fdp:consume_integer(MIN_INT, MAX_INT)
2731
local i = fdp:consume_integer(1, MAX_INT)
2832
os.setlocale(test_lib.random_locale(fdp), "all")
29-
utf8.offset(s, n, i)
33+
local err_handler = test_lib.err_handler(ignored_msgs)
34+
local ok, _ = xpcall(utf8.offset, err_handler, s, n, i)
35+
if not ok then return end
3036
end
3137

3238
local args = {

0 commit comments

Comments
 (0)