aboutsummaryrefslogtreecommitdiffstats
path: root/test/lua/unit/utf.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-02-28 10:31:47 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-02-28 10:31:47 +0000
commite866150369bfbdf594612b53262f0ad7aa5d3524 (patch)
treedd2ef189d0b5c0a468335298eea3371ef7062a87 /test/lua/unit/utf.lua
parentc0cb4e65ad38198b8112238995b224b64e83c901 (diff)
downloadrspamd-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.lua23
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