dovecot-2.0-pigeonhole: Fixed small bug in the i;ascii-numeric c...

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Tue Jan 19 21:12:22 EET 2010


details:   http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/fa4c1c24aced
changeset: 1213:fa4c1c24aced
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Tue Jan 19 16:32:48 2010 +0100
description:
Fixed small bug in the i;ascii-numeric comparator and added extensive relational tests to the testsuite.

diffstat:

 Makefile.am                                                                |    1 +
 src/lib-sieve/plugins/comparator-i-ascii-numeric/ext-cmp-i-ascii-numeric.c |    2 +-
 tests/extensions/relational/comparators.svtest                             |  189 +++++++++
 3 files changed, 191 insertions(+), 1 deletions(-)

diffs (216 lines):

diff -r 123d03cd8fe1 -r fa4c1c24aced Makefile.am
--- a/Makefile.am	Tue Jan 19 10:12:00 2010 +0100
+++ b/Makefile.am	Tue Jan 19 16:32:48 2010 +0100
@@ -86,6 +86,7 @@
 	tests/extensions/relational/basic.svtest \
 	tests/extensions/relational/rfc.svtest \
 	tests/extensions/relational/errors.svtest \
+	tests/extensions/relational/comparators.svtest \
 	tests/extensions/subaddress/basic.svtest \
 	tests/extensions/subaddress/rfc.svtest \
 	tests/extensions/subaddress/config.svtest \
diff -r 123d03cd8fe1 -r fa4c1c24aced src/lib-sieve/plugins/comparator-i-ascii-numeric/ext-cmp-i-ascii-numeric.c
--- a/src/lib-sieve/plugins/comparator-i-ascii-numeric/ext-cmp-i-ascii-numeric.c	Tue Jan 19 10:12:00 2010 +0100
+++ b/src/lib-sieve/plugins/comparator-i-ascii-numeric/ext-cmp-i-ascii-numeric.c	Tue Jan 19 16:32:48 2010 +0100
@@ -106,7 +106,7 @@
 	if ( !i_isdigit(*vp) ) {
 		if ( i_isdigit(*kp) ) {
 			/* Value is greater */
-			return -1;
+			return 1;
 		}
 	} else {
 		if ( !i_isdigit(*kp) ) {
diff -r 123d03cd8fe1 -r fa4c1c24aced tests/extensions/relational/comparators.svtest
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/extensions/relational/comparators.svtest	Tue Jan 19 16:32:48 2010 +0100
@@ -0,0 +1,189 @@
+require "vnd.dovecot.testsuite";
+require "variables";
+require "relational";
+require "comparator-i;ascii-numeric";
+
+test "i;octet" {
+	if not string :comparator "i;octet" :value "eq" "" "" {
+		test_fail "not '' eq ''";
+	}
+
+	if not string :comparator "i;octet" :value "gt" "a" "" {
+		test_fail "not 'a' gt ''";
+	}
+
+	if not string :comparator "i;octet" :value "lt" "" "a" {
+		test_fail "not '' lt 'a'";
+	}
+
+	if not string :comparator "i;octet" :value "gt" "ab" "a" {
+		test_fail "not 'ab' gt 'a'";
+	}
+
+	if not string :comparator "i;octet" :value "lt" "a" "ab" {
+		test_fail "not 'a' lt 'ab'";
+	}
+
+	if not string :comparator "i;octet" :value "gt" "ba" "ab" {
+		test_fail "not 'ba' gt 'ab'";
+	}
+
+	if not string :comparator "i;octet" :value "lt" "ab" "ba" {
+		test_fail "not 'ab' lt 'ba'";
+	}
+
+	if not string :comparator "i;octet" :value "eq" "abcd" "abcd" {
+		test_fail "not 'abcd' eq 'abcd'";
+	}
+
+	if not string :comparator "i;octet" :value "lt" "abcce" "abcde" {
+		test_fail "not 'abcce' lt 'abcde'";
+	}
+
+	if not string :comparator "i;octet" :value "gt" "abcde" "abcce" {
+		test_fail "not 'abcde' gt 'abcce'";
+	}
+
+	if not string :comparator "i;octet" :value "lt" "abcce" "abcd" {
+        test_fail "not 'abcce' lt 'abcd'";
+    }
+
+    if not string :comparator "i;octet" :value "gt" "abcd" "abcce" {
+        test_fail "not 'abcd' gt 'abcce'";
+    }
+
+    if not string :comparator "i;octet" :value "lt" "Z" "b" {
+        test_fail "not 'Z' lt 'b'";
+    }
+}
+
+test "i;ascii-casemap" {
+	if not string :comparator "i;ascii-casemap" :value "eq" "" "" {
+		test_fail "not '' eq ''";
+	}
+
+	if not string :comparator "i;ascii-casemap" :value "gt" "a" "" {
+		test_fail "not 'a' gt ''";
+	}
+
+	if not string :comparator "i;ascii-casemap" :value "lt" "" "a" {
+		test_fail "not '' lt 'a'";
+	}
+
+	if not string :comparator "i;ascii-casemap" :value "gt" "ab" "a" {
+		test_fail "not 'ab' gt 'a'";
+	}
+
+	if not string :comparator "i;ascii-casemap" :value "lt" "a" "ab" {
+		test_fail "not 'a' lt 'ab'";
+	}
+
+	if not string :comparator "i;ascii-casemap" :value "gt" "ba" "ab" {
+		test_fail "not 'ba' gt 'ab'";
+	}
+
+	if not string :comparator "i;ascii-casemap" :value "lt" "ab" "ba" {
+		test_fail "not 'ab' lt 'ba'";
+	}
+
+	if not string :comparator "i;ascii-casemap" :value "eq" "abcd" "abcd" {
+		test_fail "not 'abcd' eq 'abcd'";
+	}
+
+	if not string :comparator "i;ascii-casemap" :value "lt" "abcce" "abcde" {
+		test_fail "not 'abcce' lt 'abcde'";
+	}
+
+	if not string :comparator "i;ascii-casemap" :value "gt" "abcde" "abcce" {
+		test_fail "not 'abcde' gt 'abcce'";
+	}
+
+	if not string :comparator "i;ascii-casemap" :value "lt" "abcce" "abcd" {
+        test_fail "not 'abcce' lt 'abcd'";
+    }
+
+    if not string :comparator "i;ascii-casemap" :value "gt" "abcd" "abcce" {
+        test_fail "not 'abcd' gt 'abcce'";
+    }
+
+    if not string :comparator "i;ascii-casemap" :value "gt" "Z" "b" {
+        test_fail "not 'Z' gt 'b'";
+    }
+}
+
+test "i;ascii-numeric" {
+	if not string :comparator "i;ascii-numeric" :value "eq" "" "" {
+		test_fail "not '' eq ''";
+	}
+
+	if not string :comparator "i;ascii-numeric" :value "eq" "a" "" {
+		test_fail "not 'a' eq ''";
+	}
+
+	if not string :comparator "i;ascii-numeric" :value "eq" "" "a" {
+		test_fail "not '' eq 'a'";
+	}
+
+	if not string :comparator "i;ascii-numeric" :value "eq" "a" "b" {
+		test_fail "not 'a' eq 'b'";
+	}
+
+	if not string :comparator "i;ascii-numeric" :value "eq" "b" "a" {
+		test_fail "not 'b' eq 'a'";
+	}
+
+	if not string :comparator "i;ascii-numeric" :value "eq" "0" "0" {
+		test_fail "not '0' eq '0'";
+	}
+
+	if not string :comparator "i;ascii-numeric" :value "eq" "0" "000" {
+		test_fail "not '0' eq '000'";
+	}	
+
+	if not string :comparator "i;ascii-numeric" :value "eq" "000" "0" {
+		test_fail "not '0' eq '000'";
+	}	
+
+	if not string :comparator "i;ascii-numeric" :value "eq" "2" "2" {
+		test_fail "not '2' eq '2'";
+	}	
+
+	if not string :comparator "i;ascii-numeric" :value "eq" "02" "0002" {
+		test_fail "not '02' eq '0002'";
+	}	
+
+	if not string :comparator "i;ascii-numeric" :value "eq" "0002" "02" {
+		test_fail "not '0002' eq '02'";
+	}	
+
+	if not string :comparator "i;ascii-numeric" :value "gt" "2" "1" {
+		test_fail "not '2' gt '1'";
+	}	
+
+	if not string :comparator "i;ascii-numeric" :value "lt" "1" "2" {
+		test_fail "not '1' lt '2'";
+	}	
+
+	if not string :comparator "i;ascii-numeric" :value "gt" "2" "001" {
+		test_fail "not '2' gt '001'";
+	}	
+
+	if not string :comparator "i;ascii-numeric" :value "lt" "001" "2" {
+		test_fail "not '001' lt '2'";
+	}	
+
+	if not string :comparator "i;ascii-numeric" :value "gt" "002" "1" {
+		test_fail "not '002' gt '1'";
+	}	
+
+	if not string :comparator "i;ascii-numeric" :value "lt" "1" "002" {
+		test_fail "not '1' lt '002'";
+	}	
+
+	if not string :comparator "i;ascii-numeric" :value "lt" "65535" "65635" {
+		test_fail "not '65535' lt '65635'";
+	}	
+	if not string :comparator "i;ascii-numeric" :value "gt" "65635" "65535" {
+		test_fail "not '65635' gt '65535'";
+	}	
+}


More information about the dovecot-cvs mailing list