summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lua/unit/rspamd_util.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/lua/unit/rspamd_util.lua b/test/lua/unit/rspamd_util.lua
index 802b400d2..859316be7 100644
--- a/test/lua/unit/rspamd_util.lua
+++ b/test/lua/unit/rspamd_util.lua
@@ -5,36 +5,42 @@ context("Rspamd util for lua - check generic functions", function()
{
input = "test1",
result = false,
+ mixed_script = false,
range_start = 0x0000,
range_end = 0x017f
},
{
input = "test test xxx",
result = false,
+ mixed_script = false,
range_start = 0x0000,
range_end = 0x017f
},
{
input = "АбЫрвАлг",
result = true,
+ mixed_script = false,
range_start = 0x0000,
range_end = 0x017f
},
{
input = "АбЫрвАлг example",
result = true,
+ mixed_script = true,
range_start = 0x0000,
range_end = 0x017f
},
{
input = "example ąłśćżłóę",
result = false,
+ mixed_script = false,
range_start = 0x0000,
range_end = 0x017f
},
{
input = "ąłśćżłóę АбЫрвАлг",
result = true,
+ mixed_script = true,
range_start = 0x0000,
range_end = 0x017f
},
@@ -64,4 +70,20 @@ context("Rspamd util for lua - check generic functions", function()
assert_equal(res["letters"], 10)
assert_equal(res["digits"], 2)
end)
+
+ for i,c in ipairs(cases) do
+ test("is_utf_mixed_script, test case #" .. i, function()
+ local actual = util.is_utf_mixed_script(c.input)
+
+ assert_equal(c.mixed_script, actual)
+ end)
+ end
+
+ test("is_utf_mixed_script, invalid utf str should return errror", function()
+ assert_error(util.is_utf_mixed_script,'\200\213\202')
+ end)
+
+ test("is_utf_mixed_script, empty str should return errror", function()
+ assert_error(util.is_utf_mixed_script,'\200\213\202')
+ end)
end)