File: modifiers.svtest

package info (click to toggle)
dovecot 1:2.3.4.1-5+deb10u1~bpo9+1
  • links: PTS, VCS
  • area: main
  • in suites: stretch-backports
  • size: 46,880 kB
  • sloc: ansic: 499,137; makefile: 7,352; sh: 5,592; cpp: 1,555; perl: 303; python: 73; xml: 44; pascal: 27
file content (160 lines) | stat: -rw-r--r-- 3,736 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
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";
    }
}