From c1e6e217447db34085d4a5a9e4952aec82bf5e25 Mon Sep 17 00:00:00 2001 From: Stephan Bosch <stephan@rename-it.nl> Date: Sun, 3 Aug 2008 23:21:02 +0200 Subject: [PATCH] Testsuite: added match values test for the :regex match --- Makefile.am | 1 + tests/match-types/regex.svtest | 35 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/match-types/regex.svtest diff --git a/Makefile.am b/Makefile.am index 4f8803dc1..ea0608c65 100644 --- a/Makefile.am +++ b/Makefile.am @@ -27,6 +27,7 @@ test_cases = \ tests/match-types/contains.svtest \ tests/match-types/matches.svtest \ tests/match-types/relational.svtest \ + tests/match-types/regex.svtest \ tests/address-parts/subaddress.svtest \ tests/extensions/encoded-character.svtest \ tests/extensions/envelope.svtest \ diff --git a/tests/match-types/regex.svtest b/tests/match-types/regex.svtest new file mode 100644 index 000000000..8e814b51a --- /dev/null +++ b/tests/match-types/regex.svtest @@ -0,0 +1,35 @@ +require "vnd.dovecot.testsuite"; + +require "regex"; +require "variables"; + +# Test overwriting only on match +test "RFC - values overwrite" { + set "sentence1" "the cat jumps off the table"; + set "sentence2" "the dog barks at the cat in the alley"; + + if not string :regex "${sentence1}" "the (.*) jumps off the (.*)" { + test_fail "failed to match first sentence"; + } + + if not string :is "${1}:${2}" "cat:table" { + test_fail "invalid match values"; + } + + if string :regex "${sentence2}" "the (.*) barks at the (.*) in the store" { + test_fail "should not have matched second sentence"; + } + + if not string :is "${1}:${2}" "cat:table" { + test_fail "should have preserved match values"; + } + + if not string :regex "${sentence2}" "the (.*) barks at the (.*) in the alley" { + test_fail "failed to match the second sentence (second time)"; + } + + if not string :is "${1}:${2}" "dog:cat" { + test_fail "should have overwritten match values"; + } +} + -- GitLab