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.

rspamd_text.lua 793B

123456789101112131415161718192021222324252627282930
  1. context("Rspamd_text:byte() test", function()
  2. local lua_util = require "lua_util"
  3. local rspamd_text = require "rspamd_text"
  4. local str = 'OMG'
  5. local txt = rspamd_text.fromstring(str)
  6. local fmt = 'case rspamd_text:byte(%s,%s)'
  7. local cases = {
  8. {'1', 'nil'},
  9. {'nil', '1'},
  10. }
  11. for start = -4, 4 do
  12. for stop = -4, 4 do
  13. table.insert(cases, {tostring(start), tostring(stop)})
  14. end
  15. end
  16. for _, case in ipairs(cases) do
  17. local name = string.format(fmt, case[1], case[2])
  18. test(name, function()
  19. local txt_bytes = {txt:byte(tonumber(case[1]), tonumber(case[2]))}
  20. local str_bytes = {str:byte(tonumber(case[1]), tonumber(case[2]))}
  21. assert_rspamd_table_eq({
  22. expect = str_bytes,
  23. actual = txt_bytes
  24. })
  25. end)
  26. end
  27. end)