File: logger.lua

package info (click to toggle)
rspamd 1.8.1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 23,572 kB
  • sloc: ansic: 348,610; asm: 12,457; perl: 2,869; pascal: 1,532; cpp: 738; python: 653; java: 433; sh: 331; sql: 312; xml: 116; makefile: 111
file content (28 lines) | stat: -rw-r--r-- 773 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
context("Logger unit tests", function()
  test("Logger functions", function()
    local log = require "rspamd_logger"
    
    local cases = {
      {'string', 'string'},
      {'%1', 'string', 'string'},
      {'%1', '1.100000', 1.1},
      {'%1', '1', 1},
      {'%1', 'true', true},
      {'%1', '{[1] = 1, [2] = test}', {1, 'test'}},
      {'%1', '{[k1] = 1, [k2] = test}', {k1=1, k2='test'}},
       {'%1', '{[1] = 1, [2] = 2.100000, [k2] = test}', {1, 2.1, k2='test'}},
      {'%s', 'true', true},
    }
    
    for _,c in ipairs(cases) do
      local s
      if c[3] then
        s = log.slog(c[1], c[3])
      else
        s = log.slog(c[1])
      end
      assert_equal(s, c[2], string.format("'%s' doesn't match with '%s'",
        c[2], s)) 
    end
  end)
end)