1require "vnd.dovecot.testsuite";
2
3/*
4 * ## RFC 5228, Section 5.9. Test size (page 29) ##
5 */
6
7/*
8 * TEST: Basic functionality
9 */
10
11/* "The "size" test deals with the size of a message.  It takes either a
12 *  tagged argument of ":over" or ":under", followed by a number
13 *  representing the size of the message.
14 *
15 *  If the argument is ":over", and the size of the message is greater
16 *  than the number provided, the test is true; otherwise, it is false.
17
18 *  If the argument is ":under", and the size of the message is less than
19 *  the number provided, the test is true; otherwise, it is false.
20 * "
21 */
22
23test_set "message" text:
24From: stephan@example.org
25To: nico@frop.example.com
26Subject:         Help
27X-A:     Text
28X-B: Text
29X-Multiline: This is a multi-line
30 header body, which should be
31 unfolded correctly.
32
33Text
34
35.
36;
37
38test "Basic functionality" {
39	if not size :under 1000 {
40		test_fail "size test produced unexpected result (1)";
41	}
42
43	if size :under 10 {
44		test_fail "size test produced unexpected result (2)";
45	}
46
47	if not size :over 10 {
48		test_fail "size test produced unexpected result (3)";
49	}
50
51	if size :over 1000 {
52		test_fail "size test produced unexpected result (4)";
53	}
54}
55
56/*
57 * TEST: Exact size
58 */
59
60/* "Note that for a message that is exactly 4,000 octets, the message is
61 *  neither ":over" nor ":under" 4000 octets.
62 * "
63 */
64
65test "Exact size" {
66	if size :under 221 {
67		test_fail "size :under matched exact limit";
68	}
69
70	if size :over 221 {
71		test_fail "size :over matched exact limit";
72	}
73}
74
75