diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-04-02 13:50:11 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-04-02 14:26:34 +0100 |
commit | 399eeb77c76eca2d87fed0616d3df384ff6332f3 (patch) | |
tree | cdf21576bf29e819f8b972fed54a45d535d36597 /test/lua/unit/utf.lua | |
parent | 4a538dc83bd4f7f2677760ea7db8ac989fadad85 (diff) | |
download | rspamd-399eeb77c76eca2d87fed0616d3df384ff6332f3.tar.gz rspamd-399eeb77c76eca2d87fed0616d3df384ff6332f3.zip |
Add fast version of ascii lowercase.
Diffstat (limited to 'test/lua/unit/utf.lua')
-rw-r--r-- | test/lua/unit/utf.lua | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/lua/unit/utf.lua b/test/lua/unit/utf.lua index 2549c501c..27988f918 100644 --- a/test/lua/unit/utf.lua +++ b/test/lua/unit/utf.lua @@ -4,6 +4,7 @@ context("UTF8 check functions", function() local ffi = require("ffi") ffi.cdef[[ void rspamd_str_lc_utf8 (char *str, unsigned int size); + void rspamd_str_lc (char *str, unsigned int size); ]] test("UTF lowercase", function() @@ -20,4 +21,20 @@ context("UTF8 check functions", function() assert_equal(s, c[2]) end end) + test("ASCII lowercase", function() + local cases = { + {"AbCdEf", "abcdef"}, + {"A", "a"}, + {"AaAa", "aaaa"}, + {"AaAaAaAa", "aaaaaaaa"} + } + + for _,c in ipairs(cases) do + local buf = ffi.new("char[?]", #c[1]) + ffi.copy(buf, c[1]) + ffi.C.rspamd_str_lc(buf, #c[1]) + local s = ffi.string(buf) + assert_equal(s, c[2]) + end + end) end)
\ No newline at end of file |