summaryrefslogtreecommitdiffstats
path: root/pigeonhole/tests/test-size.svtest
blob: dd5cdc4f42e55abd98b645e5166a487033a6ec99 (plain)
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
require "vnd.dovecot.testsuite";

/*
 * ## RFC 5228, Section 5.9. Test size (page 29) ##
 */

/*
 * TEST: Basic functionality
 */

/* "The "size" test deals with the size of a message.  It takes either a
 *  tagged argument of ":over" or ":under", followed by a number
 *  representing the size of the message.
 *
 *  If the argument is ":over", and the size of the message is greater
 *  than the number provided, the test is true; otherwise, it is false.

 *  If the argument is ":under", and the size of the message is less than
 *  the number provided, the test is true; otherwise, it is false.
 * "
 */

test_set "message" text:
From: stephan@example.org
To: nico@frop.example.com
Subject:         Help        
X-A:     Text
X-B: Text            
X-Multiline: This is a multi-line
 header body, which should be
 unfolded correctly.

Text

.
;

test "Basic functionality" {
	if not size :under 1000 {
		test_fail "size test produced unexpected result (1)";
	}

	if size :under 10 {
		test_fail "size test produced unexpected result (2)";
	}

	if not size :over 10 {
		test_fail "size test produced unexpected result (3)";
	}

	if size :over 1000 {
		test_fail "size test produced unexpected result (4)";
	}
}

/*
 * TEST: Exact size
 */

/* "Note that for a message that is exactly 4,000 octets, the message is
 *  neither ":over" nor ":under" 4000 octets.
 * "
 */

test "Exact size" {
	if size :under 221 {
		test_fail "size :under matched exact limit";
	}

	if size :over 221 {
		test_fail "size :over matched exact limit";
	}
}