Skip to content
Snippets Groups Projects
Commit cf33f358 authored by Stephan Bosch's avatar Stephan Bosch
Browse files

Testsuite: added simple tests for the match values produced by the :regex match.

parent 8fa2ee03
No related branches found
No related tags found
No related merge requests found
......@@ -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 \
......
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}";
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.