File: test-exists.svtest

package info (click to toggle)
dovecot 1%3A2.1.7-7%2Bdeb7u1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 33,368 kB
  • sloc: ansic: 284,478; sh: 23,068; makefile: 4,874; cpp: 1,381; perl: 263; xml: 45; python: 34; pascal: 27
file content (93 lines) | stat: -rw-r--r-- 2,012 bytes parent folder | download
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
require "vnd.dovecot.testsuite";

/* "The "exists" test is true if the headers listed in the header-names
 *  argument exist within the message.  All of the headers must exist or
 *  the test is false.
 * "
 */
 
test_set "message" text:
From: stephan@example.org
To: nico@vestingbar.bl
Subject: Test message
Date: Wed, 29 Jul 2009 18:21:44 +0300
X-Spam-Status: Not Spam
Resent-To: nico@frop.example.com

Test!
.
;

/*
 * TEST: One header
 */

test "One header" {
	if not exists "from" {
		test_fail "exists test missed from header";
	}

	if exists "x-nonsense" {
		test_fail "exists test found non-existent header";
	}
}

/*
 * TEST: Two headers
 */

test "Two headers" {
	if not exists ["from","to"] {
		test_fail "exists test missed from or to header";
	}

	if exists ["from","x-nonsense"] {
		test_fail "exists test found non-existent header (1)";
	}

	if exists ["x-nonsense","to"] {
		test_fail "exists test found non-existent header (2)";
	}

	if exists ["x-nonsense","x-nonsense2"] {
		test_fail "exists test found non-existent header (3)";
	}
}

/*
 * TEST: Three headers
 */

test "Three headers" {
	if not exists ["Subject","date","resent-to"] {
		test_fail "exists test missed subject, date or resent-to header";
	}

	if exists ["x-nonsense","date","resent-to"] {
		test_fail "exists test found non-existent header (1)";
	}

	if exists ["subject", "x-nonsense","resent-to"] {
		test_fail "exists test found non-existent header (2)";
	}

	if exists ["subject","date","x-nonsense"] {
		test_fail "exists test found non-existent header (3)";
	}

	if exists ["subject", "x-nonsense","x-nonsense2"] {
		test_fail "exists test found non-existent header (4)";
	}

	if exists ["x-nonsense","date","x-nonsense2"] {
		test_fail "exists test found non-existent header (5)";
	}

	if exists ["x-nonsense","x-nonsense2","resent-to"] {
		test_fail "exists test found non-existent header (6)";
	}

	if exists ["x-nonsense","x-nonsense2","x-nonsense3"] {
		test_fail "exists test found non-existent header (7)";
	}
}