summaryrefslogtreecommitdiffstats
path: root/pigeonhole/tests/extensions/variables/modifiers.svtest
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:51:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:51:24 +0000
commitf7548d6d28c313cf80e6f3ef89aed16a19815df1 (patch)
treea3f6f2a3f247293bee59ecd28e8cd8ceb6ca064a /pigeonhole/tests/extensions/variables/modifiers.svtest
parentInitial commit. (diff)
downloaddovecot-f7548d6d28c313cf80e6f3ef89aed16a19815df1.tar.xz
dovecot-f7548d6d28c313cf80e6f3ef89aed16a19815df1.zip
Adding upstream version 1:2.3.19.1+dfsg1.upstream/1%2.3.19.1+dfsg1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'pigeonhole/tests/extensions/variables/modifiers.svtest')
-rw-r--r--pigeonhole/tests/extensions/variables/modifiers.svtest160
1 files changed, 160 insertions, 0 deletions
diff --git a/pigeonhole/tests/extensions/variables/modifiers.svtest b/pigeonhole/tests/extensions/variables/modifiers.svtest
new file mode 100644
index 0000000..37068b6
--- /dev/null
+++ b/pigeonhole/tests/extensions/variables/modifiers.svtest
@@ -0,0 +1,160 @@
+require "vnd.dovecot.testsuite";
+require "variables";
+require "encoded-character";
+
+/*
+ * Modifiers
+ */
+
+test "Modifier :lower" {
+ set :lower "test" "VaLuE";
+
+ if not string :is "${test}" "value" {
+ test_fail "modified variable assignment failed";
+ }
+}
+
+test "Modifiers :lower :upperfirst" {
+ set :lower :upperfirst "test" "vAlUe";
+
+ if string :is "${test}" "value" {
+ test_fail "modifiers applied with wrong precedence";
+ }
+
+ if not string :is "${test}" "Value" {
+ test_fail "modified variable assignment failed";
+ }
+}
+
+test "Modifiers :upperfirst :lower" {
+ set :upperfirst :lower "test" "vAlUe";
+
+ if string :is "${test}" "value" {
+ test_fail "modifiers applied with wrong precedence";
+ }
+
+ if not string :is "${test}" "Value" {
+ test_fail "modified variable assignment failed";
+ }
+}
+
+test "Modifier :upper" {
+ set :upper "test" "vAlUe";
+
+ if not string :is "${test}" "VALUE" {
+ test_fail "modified variable assignment failed";
+ }
+}
+
+test "Modifiers :upper :lowerfirst" {
+ set :upper :lowerfirst "test" "VaLuE";
+
+ if string :is "${test}" "VALUE" {
+ test_fail "modifiers applied with wrong precedence";
+ }
+
+ if not string :is "${test}" "vALUE" {
+ test_fail "modified variable assignment failed";
+ }
+}
+
+test "Modifiers :lowerfirst :upper" {
+ set :lowerfirst :upper "test" "VaLuE";
+
+ if string :is "${test}" "VALUE" {
+ test_fail "modifiers applied with wrong precedence";
+ }
+
+ if not string :is "${test}" "vALUE" {
+ test_fail "modified variable assignment failed";
+ }
+}
+
+test "Modifier :length (empty)" {
+ set :length "test" "";
+
+ if not string :is "${test}" "0" {
+ test_fail "modified variable assignment failed";
+ }
+}
+
+test "Modifier :length (simple)" {
+ set :length "test" "VaLuE";
+
+ if not string :is "${test}" "5" {
+ test_fail "modified variable assignment failed";
+ }
+}
+
+test "Modifier :length (elaborate)" {
+ set "a" "abcdefghijklmnopqrstuvwxyz";
+ set "b" "1234567890";
+ set :length "test" " ${a}:${b} ";
+
+ if not string :is "${test}" "40" {
+ test_fail "modified variable assignment failed";
+ }
+}
+
+test "Modifier :quotewildcard" {
+ set :quotewildcard "test" "^^***??**^^";
+
+ if not string :is "${test}" "^^\\*\\*\\*\\?\\?\\*\\*^^" {
+ test_fail "modified variable assignment failed";
+ }
+}
+
+test "Modifier :length :quotewildcard" {
+ set :length :quotewildcard "test" "^^***??**^^";
+
+ if string :is "${test}" "11" {
+ test_fail "modifiers applied with wrong precedence";
+ }
+
+ if not string :is "${test}" "18" {
+ test_fail "modified variable assignment failed";
+ }
+}
+
+test "RFC examples" {
+ set "a" "juMBlEd lETteRS"; # => "juMBlEd lETteRS"
+ if not string "${a}" "juMBlEd lETteRS" {
+ test_fail "modified assignment failed (1): ${a}";
+ }
+
+ set :length "b" "${a}"; # => "15"
+ if not string "${b}" "15" {
+ test_fail "modified assignment failed (2): ${a}";
+ }
+
+ set :lower "b" "${a}"; # => "jumbled letters"
+ if not string "${b}" "jumbled letters" {
+ test_fail "modified assignment failed (3): ${a}";
+ }
+
+ set :upperfirst "b" "${a}"; # => "JuMBlEd lETteRS"
+ if not string "${b}" "JuMBlEd lETteRS" {
+ test_fail "modified assignment failed (4): ${a}";
+ }
+
+ set :upperfirst :lower "b" "${a}"; # => "Jumbled letters"
+ if not string "${b}" "Jumbled letters" {
+ test_fail "modified assignment failed (5): ${a}";
+ }
+
+ set :quotewildcard "b" "Rock*"; # => "Rock\*"
+ if not string "${b}" "Rock\\*" {
+ test_fail "modified assignment failed (6): ${a}";
+ }
+}
+
+/* RFC mentions `characters' and not octets */
+
+test "Modifier :length utf8" {
+ set "a" "Das ist ${unicode: 00fc}berhaupt nicht m${unicode: 00f6}glich.";
+
+ set :length "b" "${a}";
+ if not string "${b}" "32" {
+ test_fail "incorrect number of unicode characters reported: ${b}/32";
+ }
+}