diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-02-28 10:31:47 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-02-28 10:31:47 +0000 |
commit | e866150369bfbdf594612b53262f0ad7aa5d3524 (patch) | |
tree | dd2ef189d0b5c0a468335298eea3371ef7062a87 /test/lua/unit/utf.lua | |
parent | c0cb4e65ad38198b8112238995b224b64e83c901 (diff) | |
download | rspamd-e866150369bfbdf594612b53262f0ad7aa5d3524.tar.gz rspamd-e866150369bfbdf594612b53262f0ad7aa5d3524.zip |
Add utf lc test case and fix the bug.
Diffstat (limited to 'test/lua/unit/utf.lua')
-rw-r--r-- | test/lua/unit/utf.lua | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/lua/unit/utf.lua b/test/lua/unit/utf.lua new file mode 100644 index 000000000..2549c501c --- /dev/null +++ b/test/lua/unit/utf.lua @@ -0,0 +1,23 @@ +-- Test utf routines + +context("UTF8 check functions", function() + local ffi = require("ffi") + ffi.cdef[[ + void rspamd_str_lc_utf8 (char *str, unsigned int size); + ]] + + test("UTF lowercase", function() + local cases = { + {"АбЫрвАлг", "абырвалг"}, + {"АAБBвc", "аaбbвc"} + } + + for _,c in ipairs(cases) do + local buf = ffi.new("char[?]", #c[1]) + ffi.copy(buf, c[1]) + ffi.C.rspamd_str_lc_utf8(buf, #c[1]) + local s = ffi.string(buf) + assert_equal(s, c[2]) + end + end) +end)
\ No newline at end of file |