File: basic.svtest

package info (click to toggle)
dovecot 1:2.2.13-12~deb8u4
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 38,792 kB
  • sloc: ansic: 341,472; sh: 16,920; makefile: 5,393; cpp: 1,474; perl: 265; xml: 44; python: 34; pascal: 27
file content (260 lines) | stat: -rw-r--r-- 5,475 bytes parent folder | download | duplicates (7)
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
require "vnd.dovecot.testsuite";

require "imap4flags";
require "relational";
require "variables";
require "comparator-i;ascii-numeric";

/*
 * Basic functionality tests
 */

test "Hasflag empty" {
	if hasflag "\\Seen" {
		test_fail "hasflag sees initial \\seen flag were there should be none";
	}
	if hasflag "\\draft" {
		test_fail "hasflag sees initial \\draft flag were there should be none";
	}
	if hasflag "\\recent" {
		test_fail "hasflag sees initial \\recent flag were there should be none";
	}
	if hasflag "\\flagged" {
		test_fail "hasflag sees initial \\flagged flag were there should be none";
	}
	if hasflag "\\answered" {
		test_fail "hasflag sees initial \\answered flag were there should be none";
	}
	if hasflag "\\deleted" {
		test_fail "hasflag sees initial \\deleted flag were there should be none";
	}

	if hasflag :comparator "i;ascii-numeric" :count "ge" "1" {
		test_fail "hasflag sees initial flags were there should be none";
	}
}

test "Setflag; Hasflag one" {
	setflag "\\seen";

	if not hasflag "\\Seen" {
		test_fail "flag not set of hasflag fails to see it";
	}

	if not hasflag :comparator "i;ascii-numeric" :count "eq" "1" {
		test_fail "flag not set of hasflag fails to see it";
	}

	if hasflag "$Nonsense" {
		test_fail "hasflag sees other flag that the one set";
	}
}

test "Hasflag; duplicates" {
	set "Flags" "A B C D E F A B C D E F";

	if hasflag :comparator "i;ascii-numeric" :count "gt" "Flags" "6" {
		test_fail "hasflag must ignore duplicates";
	}

	if not hasflag :comparator "i;ascii-numeric" :count "eq" "Flags" "6" {
		test_fail "hasflag :count gives strange results";
	}
}

test "Flag operations" {
	setflag "A";

	if not hasflag "A" {
		test_fail "hasflag misses set flag";
	}

	if hasflag :comparator "i;ascii-numeric" :count "gt" "1" {
		test_fail "hasflag sees more than one flag";
	}

	addflag "B";

	if not hasflag "B" {
		test_fail "flag \"B\" not added";
	}

	if not hasflag "A" {
		test_fail "flag \"A\" not retained";
	}

	if hasflag :comparator "i;ascii-numeric" :count "gt" "2" {
		test_fail "hasflag sees more than two flags";
	}

	addflag ["C", "D", "E F"];

	if not hasflag :comparator "i;ascii-numeric" :count "eq" "6" {
		test_fail "hasflag sees more than two flags";
	}

	removeflag ["D"];

	if not hasflag :comparator "i;ascii-numeric" :count "eq" "5" {
		test_fail "hasflag sees more than two flags";
	}

	if hasflag "D" {
		test_fail "removed flag still present";
	}
}

test "Setflag; string list" {
	setflag ["A B", "C D"];

	if not hasflag "A" {
		test_fail "hasflag misses A flag";
	}

	if not hasflag "B" {
		test_fail "hasflag misses B flag";
	}

	if not hasflag "C" {
		test_fail "hasflag misses C flag";
	}

	if not hasflag "D" {
		test_fail "hasflag misses D flag";
	}

	if hasflag :comparator "i;ascii-numeric" :count "ne" "4" {
		test_fail "hasflag sees incorrect number of flags";
	}
}

test "Removal: one" {
	setflag "\\seen";

	if not hasflag "\\seen" {
		test_fail "hasflag misses set flag";
	}

	removeflag "\\seen";

	if hasflag "\\seen" {
		test_fail "flag not removed";
	}

	if not hasflag :comparator "i;ascii-numeric" :count "eq" "0" {
		test_fail "flags are still set";
	}
}

test "Removal: first" {
	setflag "$frop \\seen";

	if not allof ( hasflag "\\seen", hasflag "$frop" ) {
		test_fail "hasflag misses set flags";
	}

	removeflag "$frop";

	if not hasflag "\\seen" {
		test_fail "wrong flag removed";
	}

	if hasflag "$frop" {
		test_fail "flag not removed";
	}

	if not hasflag :comparator "i;ascii-numeric" :count "eq" "1" {
		test_fail "more than one flag remains set";
	}
}

test "Removal: last" {
	setflag "\\seen $friep";

	if not allof ( hasflag "\\seen", hasflag "$friep" ) {
		test_fail "hasflag misses set flags";
	}

	removeflag "$friep";

	if not hasflag "\\seen" {
		test_fail "wrong flag removed";
	}

	if hasflag "$friep" {
		test_fail "flag not removed";
	}

	if not hasflag :comparator "i;ascii-numeric" :count "eq" "1" {
		test_fail "more than one flag remains set";
	}
}

test "Removal: middle" {
	setflag "\\seen $friep \\flagged";

	if not allof ( hasflag "\\flagged", hasflag "\\seen", hasflag "$friep" ) {
		test_fail "hasflag misses set flags";
	}

	removeflag "$friep";

	if not allof ( hasflag "\\seen", hasflag "\\flagged" ) {
		test_fail "wrong flag removed";
	}

	if hasflag "$friep" {
		test_fail "flag not removed";
	}

	if not hasflag :comparator "i;ascii-numeric" :count "eq" "2" {
		test_fail "more than two flags remain set";
	}
}

test "Removal: duplicates" {
	setflag "\\seen $friep $friep \\flagged $friep";

	if not allof ( hasflag "\\flagged", hasflag "\\seen", hasflag "$friep" ) {
		test_fail "hasflag misses set flags";
	}

	removeflag "$friep";

	if not allof ( hasflag "\\seen", hasflag "\\flagged" ) {
		test_fail "wrong flag removed";
	}

	if hasflag "$friep" {
		test_fail "flag not removed";
	}

	if not hasflag :comparator "i;ascii-numeric" :count "eq" "2" {
		test_fail "more than two flags remain set";
	}
}

test "Removal: whitespace" {
	setflag "   \\seen     $friep      $friep   \\flagged    $friep   ";

	if not allof ( hasflag "\\flagged", hasflag "\\seen", hasflag "$friep" ) {
		test_fail "hasflag misses set flags";
	}

	removeflag "$friep";

	if not allof ( hasflag "\\seen", hasflag "\\flagged" ) {
		test_fail "wrong flag removed";
	}

	if hasflag "$friep" {
		test_fail "flag not removed";
	}

	if not hasflag :comparator "i;ascii-numeric" :count "eq" "2" {
		test_fail "more than two flags remain set";
	}
}