From cf33f3589e7e49e0798f0cac75df32ae64686d22 Mon Sep 17 00:00:00 2001 From: Stephan Bosch <stephan@rename-it.nl> Date: Thu, 22 Jan 2009 00:20:10 +0100 Subject: [PATCH] Testsuite: added simple tests for the match values produced by the :regex match. --- Makefile.am | 1 + tests/extensions/regex/match-values.svtest | 68 ++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 tests/extensions/regex/match-values.svtest diff --git a/Makefile.am b/Makefile.am index c9638a16a..fd136e063 100644 --- a/Makefile.am +++ b/Makefile.am @@ -61,6 +61,7 @@ test_cases = \ tests/extensions/body/basic.svtest \ tests/extensions/body/match-values.svtest \ tests/extensions/regex/basic.svtest \ + tests/extensions/regex/match-values.svtest \ tests/extensions/regex/errors.svtest \ tests/extensions/reject/execute.svtest \ tests/extensions/relational/basic.svtest \ diff --git a/tests/extensions/regex/match-values.svtest b/tests/extensions/regex/match-values.svtest new file mode 100644 index 000000000..04506a684 --- /dev/null +++ b/tests/extensions/regex/match-values.svtest @@ -0,0 +1,68 @@ +require "vnd.dovecot.testsuite"; + +require "regex"; +require "variables"; + +test_set "message" text: +From: Andy Howell <AndyHowell@example.com> +Sender: antlr-interest-bounces@antlr.org +To: Stephan Bosch <stephan@rename-it.nl> +Subject: [Dovecot] Sieve regex match problem + +Hi, + +I is broken. +. +; + +test "Basic match values 1" { + if header :regex ["Sender"] ["([^-@]*)-([^-@]*)(-bounces)?@antlr.org"] { + + if not string :is "${1}" "antlr" { + test_fail "first match value is not correct"; + } + + if not string :is "${2}" "interest" { + test_fail "second match value is not correct"; + } + + if not string :is "${3}" "-bounces" { + test_fail "third match value is not correct"; + } + + if string :is "${4}" "-bounces" { + test_fail "fourth match contains third value"; + } + } +} + +test "Basic match values 2" { + if header :regex ["Sender"] ["(.*>[ \\t]*,?[ \\t]*)?([^-@]*)-([^-@]*)(-bounces)?@antlr.org"] { + + if not string :is "${1}" "" { + test_fail "first match value is not correct: ${1}"; + } + + if not string :is "${2}" "antlr" { + test_fail "second match value is not correct: ${2}"; + } + + if not string :is "${3}" "interest" { + test_fail "third match value is not correct: ${3}"; + } + + if not string :is "${4}" "-bounces" { + test_fail "fourth match value is not correct: ${4}"; + } + + if string :is "${5}" "-bounces" { + test_fail "fifth match contains fourth value: ${5}"; + } + } +} + + + + + + -- GitLab