diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-06-30 18:26:48 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-06-30 18:26:48 +0100 |
commit | 0e85c23ee12fa524ac9056ee0275fd3c4b15c612 (patch) | |
tree | ba0fcbe01a55297f9264762022bbfa68daa20559 /test | |
parent | f826e627cf53496b3ec79be2cc72a5445c89db19 (diff) | |
download | rspamd-0e85c23ee12fa524ac9056ee0275fd3c4b15c612.tar.gz rspamd-0e85c23ee12fa524ac9056ee0275fd3c4b15c612.zip |
Fix issues with capturing patterns
Diffstat (limited to 'test')
-rw-r--r-- | test/lua/unit/regxep.lua | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/test/lua/unit/regxep.lua b/test/lua/unit/regxep.lua index 8ee26be07..d0b1c422f 100644 --- a/test/lua/unit/regxep.lua +++ b/test/lua/unit/regxep.lua @@ -35,8 +35,13 @@ context("Regexp unit tests", function() test("Regexp capture", function() local cases = { {'Body=(\\S+)(?: Fuz1=(\\S+))?(?: Fuz2=(\\S+))?', - 'mc-filter4 1120; Body=1 Fuz1=1 Fuz2=1', - {'Body=1 Fuz1=1 Fuz2=1', '1', '1', '1'}} + 'mc-filter4 1120; Body=1 Fuz1=2 Fuz2=3', + {'Body=1 Fuz1=2 Fuz2=3', '1', '2', '3'}}, + {'Body=(\\S+)(?: Fuz1=(\\S+))?(?: Fuz2=(\\S+))?', + 'mc-filter4 1120; Body=1 Fuz1=2', {'Body=1 Fuz1=2', '1', '2'}}, + {'Body=(\\S+)(?: Fuz1=(\\S+))?(?: Fuz2=(\\S+))?', + 'mc-filter4 1120; Body=1 Fuz1=2 mc-filter4 1120; Body=1 Fuz1=2 Fuz2=3', + {'Body=1 Fuz1=2', '1', '2'}, {'Body=1 Fuz1=2 Fuz2=3', '1', '2', '3'}}, } for _,c in ipairs(cases) do local r = re.create_cached(c[1]) @@ -45,9 +50,11 @@ context("Regexp unit tests", function() assert_not_nil(res, "cannot find pattern") - for n,m in ipairs(res[1]) do - assert_equal(m, c[3][n], string.format("'%s' doesn't match with '%s'", - c[3][n], c[1])) + for k = 3, table.maxn(c) do + for n,m in ipairs(c[k]) do + assert_equal(res[k - 2][n], c[k][n], string.format("'%s' doesn't match with '%s'", + c[k][n], res[k - 2][n])) + end end end end) |