From 43d05ac54720504d318ae18018135420d87e32aa Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan@rename-it.nl>
Date: Mon, 28 Jul 2008 14:59:16 +0200
Subject: [PATCH] Testsuite: marginally improved match-type tests.

---
 TODO                                          |  6 +++-
 src/testsuite/Makefile.am                     |  1 +
 .../tests/match-types/contains.svtest         | 30 ++++++++++++-------
 src/testsuite/tests/match-types/is.svtest     | 17 +++++++++++
 4 files changed, 43 insertions(+), 11 deletions(-)
 create mode 100644 src/testsuite/tests/match-types/is.svtest

diff --git a/TODO b/TODO
index a72c980dd..07a50b0ea 100644
--- a/TODO
+++ b/TODO
@@ -3,6 +3,10 @@ Next (in order of descending priority/precedence):
 
 * Full standards compliance review for the engine and all fully implemented 
   sieve extensions. Issues discovered so far:
+	- :matches : match values must only be changed when the test 
+	  matches.
+	- If an address is not syntactically valid, then it will not be matched
+	  by tests specifying ":localpart" or ":domain".
 	- Fix/Report issues listed in 'doc/rfc/RFC Controversy.txt'
 * Code cleanup 
 * Full security review. Enforce limits on number of created objects, script 
@@ -26,6 +30,7 @@ Next (in order of descending priority/precedence):
 * Verify outgoing mail addresses at runtime when necessary (e.g. after variables 
   substitution)
 * Warn about the use of syntactically invalid header names. 
+* Implement notify extension with sole support for mailto mechanism. 
 * Implement dropping errors in the user's mailbox as a mail message.
 * Provide a solution for mail_get_headers_utf8 reparsing the whole message each
   time it is called (header and address test; Timo might provide solution from
@@ -39,7 +44,6 @@ Next (in order of descending priority/precedence):
   same set of result actions.
 * Implement comparator-i;unicode-casemap
 * Implement environment extension
-* Implement notify extension with sole support for mailto mechanism. 
 * Implement date and index extensions
 * Optimize code containing true/false tests to omit explicit JMP opcodes
   (i.e. optimize the test away and any code that negatively depends on it)
diff --git a/src/testsuite/Makefile.am b/src/testsuite/Makefile.am
index 72fa36937..f34458adb 100644
--- a/src/testsuite/Makefile.am
+++ b/src/testsuite/Makefile.am
@@ -71,6 +71,7 @@ test_cases = \
 	tests/exists.svtest \
 	tests/lexer.svtest \
 	tests/comparators/core.svtest \
+	tests/match-types/is.svtest \
 	tests/match-types/contains.svtest \
 	tests/match-types/matches.svtest \
 	tests/match-types/relational.svtest \
diff --git a/src/testsuite/tests/match-types/contains.svtest b/src/testsuite/tests/match-types/contains.svtest
index 04ec68456..d8f512285 100644
--- a/src/testsuite/tests/match-types/contains.svtest
+++ b/src/testsuite/tests/match-types/contains.svtest
@@ -13,51 +13,61 @@ Test!
 
 # Match tests
 
-test "MATCH-full" {
+test "Match empty" {
+	if not header :contains "x-bullshit" "" {
+		test_fail "contains tests fails to match \"\"";
+	}
+}
+
+test "Match full" {
 	if not address :contains "from" "stephan@rename-it.nl" {
 		test_fail "should have matched";
 	}
 }
 
-test "MATCH-begin" {
+test "Match begin" {
 	if not address :contains "from" "stephan" {
 		test_fail "should have matched";
 	}
 }
 
-test "MATCH-end" {
+test "Match end" {
 	if not address :contains "from" "rename-it.nl" {
 		test_fail "should have matched";
 	}
 }
 
-test "MATCH-middle" {
+test "Match middle" {
 	if not address :contains "from" "@" {
 		test_fail "should have matched";
 	}
 }
 
-test "MATCH-similar-beginnings" {
+test "Match similar beginnings" {
 	if not header :contains "x-bullshit" "frobnitzn" {
 		test_fail "should have matched";
 	}
 }
 
-test "MATCH-empty" {
-	if not header :contains "x-bullshit" "" {
-		test_fail "contains tests fails to match \"\"";
+test "Match case-insensitive" {
+	if not address :contains :comparator "i;ascii-casemap" "from" "RENAME-IT" {
+		test_fail "match fails to apply correct comparator";	
 	}
+
+	if address :contains "from" "RENAME-IT" {
+        test_fail "default comparator is wrong";
+    }
 }
 
 # Non-match tests
 
-test "NO-MATCH-full-typo" {
+test "No match full (typo)" {
 	if address :contains "to" "frob@example.com" {
 		test_fail "should not have matched";
 	}
 }
 
-test "NO-MATCH-end-typo" {
+test "No match end (typo)" {
 	if header :contains "x-bullshit" "frobnitzm" {
 		test_fail "should not have matched";
 	}
diff --git a/src/testsuite/tests/match-types/is.svtest b/src/testsuite/tests/match-types/is.svtest
new file mode 100644
index 000000000..05a6261bd
--- /dev/null
+++ b/src/testsuite/tests/match-types/is.svtest
@@ -0,0 +1,17 @@
+require "vnd.dovecot.testsuite";
+
+test_set "message" text:
+From: Stephan Bosch <stephan@rename-it.nl>
+To: nico@vestingbar.nl
+Subject: Test message
+
+Test!
+
+.
+;
+
+test "Empty key" {
+	if header :is "from" "" {
+		test_fail "erroneously matched empty key"; 
+	}
+}
-- 
GitLab