File: hasflag.svtest

package info (click to toggle)
dovecot 1%3A2.2.27-3~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 48,308 kB
  • sloc: ansic: 430,242; sh: 17,401; makefile: 6,581; cpp: 1,557; perl: 295; xml: 44; pascal: 27; python: 27
file content (91 lines) | stat: -rw-r--r-- 1,834 bytes parent folder | download | duplicates (14)
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
require "vnd.dovecot.testsuite";

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

/*
 * Generic tests
 */

test "Ignoring \"\"" {
	setflag "";

	if hasflag "" {
		test_fail "hasflag fails to ignore empty string";
	}
}

/*
 * Variables
 */

test "Multiple variables" {
	setflag "A" "Aflag";
	setflag "B" "Bflag";
	setflag "C" "Cflag";

	if not hasflag ["a", "b", "c"] ["Bflag"] {
		test_fail "hasflag failed to match multiple flags variables";
	}
}

/*
 * RFC examples
 */

test "RFC hasflag example - :is" {
	setflag "A B";

	if not hasflag ["b","A"] {
		test_fail "list representation did not match";
	}

	if not hasflag :is "b A" {
		test_fail "string representation did not match";
	}
}

test "RFC hasflag example - :contains variable" {
	set "MyVar" "NonJunk Junk gnus-forward $Forwarded NotJunk JunkRecorded $Junk $NotJunk";

	if not hasflag :contains "MyVar" "Junk" {
		test_fail "failed true example 1";
	}

	if not hasflag :contains "MyVar" "forward" {
		test_fail "failed true example 2";
	}

	if not hasflag :contains "MyVar" ["label", "forward"] {
		test_fail "failed true example 3";
	}

	if not hasflag :contains "MyVar" ["junk", "forward"] {
		test_fail "failed true example 4";
	}

	if not hasflag :contains "MyVar" "junk forward" {
		test_fail "failed true example 4 (rewrite 1)";
	}

	if not hasflag :contains "MyVar" "forward junk" {
		test_fail "failed true example 4 (rewrite 2)";
	}

	if hasflag :contains "MyVar" "label" {
		test_fail "failed false example 1";
	}

	if hasflag :contains "MyVar" ["label1", "label2"] {
		test_fail "failed false example 2";
	}
}

test "RFC hasflag example - :count variable" {
	set "MyFlags" "A B";
	if not hasflag :count "ge" :comparator "i;ascii-numeric" "MyFlags" "2" {
		test_fail "failed count \"ge\" comparison";
	}
}