mirror of https://github.com/rspamd/rspamd.git
Rapid spam filtering system
https://rspamd.com/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
793 B
30 lines
793 B
context("Rspamd_text:byte() test", function()
|
|
local lua_util = require "lua_util"
|
|
local rspamd_text = require "rspamd_text"
|
|
|
|
local str = 'OMG'
|
|
local txt = rspamd_text.fromstring(str)
|
|
local fmt = 'case rspamd_text:byte(%s,%s)'
|
|
local cases = {
|
|
{'1', 'nil'},
|
|
{'nil', '1'},
|
|
}
|
|
|
|
for start = -4, 4 do
|
|
for stop = -4, 4 do
|
|
table.insert(cases, {tostring(start), tostring(stop)})
|
|
end
|
|
end
|
|
|
|
for _, case in ipairs(cases) do
|
|
local name = string.format(fmt, case[1], case[2])
|
|
test(name, function()
|
|
local txt_bytes = {txt:byte(tonumber(case[1]), tonumber(case[2]))}
|
|
local str_bytes = {str:byte(tonumber(case[1]), tonumber(case[2]))}
|
|
assert_rspamd_table_eq({
|
|
expect = str_bytes,
|
|
actual = txt_bytes
|
|
})
|
|
end)
|
|
end
|
|
end)
|