aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-07-20 22:52:20 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-07-20 22:52:20 +0100
commit39f580451550ff4f08fc3a26a0b2455675a27ab9 (patch)
tree4294b9bfe4cd7b2ee9d2b7a0749509140976919f /test
parent028de314820e841d9a892a5f15067617deaba8b8 (diff)
downloadrspamd-39f580451550ff4f08fc3a26a0b2455675a27ab9.tar.gz
rspamd-39f580451550ff4f08fc3a26a0b2455675a27ab9.zip
Add unit tests for the new mempool variables.
Diffstat (limited to 'test')
-rw-r--r--test/lua/unit/mempool.lua37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/lua/unit/mempool.lua b/test/lua/unit/mempool.lua
new file mode 100644
index 000000000..2afaad7ec
--- /dev/null
+++ b/test/lua/unit/mempool.lua
@@ -0,0 +1,37 @@
+context("Memory pool unit tests", function()
+ test("Mempool variables", function()
+ local mempool = require "rspamd_mempool"
+
+ local pool = mempool.create()
+
+ assert_not_nil(pool)
+
+ -- string
+ pool:set_variable('a', 'bcd')
+ local var = pool:get_variable('a')
+ assert_equal(var, 'bcd')
+
+ -- integer
+ pool:set_variable('a', 1)
+ var = pool:get_variable('a', 'double')
+ assert_equal(var, 1)
+
+ -- float
+ pool:set_variable('a', 1.01)
+ var = pool:get_variable('a', 'double')
+ assert_equal(var, 1.01)
+
+ -- boolean
+ pool:set_variable('a', false)
+ var = pool:get_variable('a', 'bool')
+ assert_equal(var, false)
+
+ -- multiple
+ pool:set_variable('a', 'bcd', 1, 1.01, false)
+ local v1, v2, v3, v4 = pool:get_variable('a', 'string,double,double,bool')
+ assert_equal(v1, 'bcd')
+ assert_equal(v2, 1)
+ assert_equal(v3, 1.01)
+ assert_equal(v4, false)
+ end)
+end) \ No newline at end of file