From 399eeb77c76eca2d87fed0616d3df384ff6332f3 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 2 Apr 2015 13:50:11 +0100 Subject: Add fast version of ascii lowercase. --- test/lua/unit/utf.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test/lua/unit/utf.lua') 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 -- cgit v1.2.3