diff options
author | Miecio Za <miecio@miecio.net> | 2019-03-26 20:23:13 +0100 |
---|---|---|
committer | Miecio Za <miecio@miecio.net> | 2019-03-26 20:23:13 +0100 |
commit | 89c5fe4c05012315e9229e033ae3ded8c31b1cd7 (patch) | |
tree | 1e83640766b9dc1a99ce36260ac122144d060d3c /test | |
parent | 7824318dca65d223df397329b3eabde86c3fde02 (diff) | |
download | rspamd-89c5fe4c05012315e9229e033ae3ded8c31b1cd7.tar.gz rspamd-89c5fe4c05012315e9229e033ae3ded8c31b1cd7.zip |
[Minor] Rewrite is_utf_mixed_script to use libicu only
Rewrite to use U8_NEXT
Diffstat (limited to 'test')
-rw-r--r-- | test/lua/unit/rspamd_util.lua | 22 |
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) |