File: date-parts.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 (120 lines) | stat: -rw-r--r-- 3,217 bytes parent folder | download | duplicates (13)
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
require "vnd.dovecot.testsuite";
require "date";
require "variables";

test_set "message" text:
From: stephan@example.org
To: sirius@friep.example.com
Subject: Frop!
Date: Mon, 20 Jul 2009 21:44:43 +0300
Delivery-Date: Mon, 22 Jul 2009 23:30:14 +0300

Wanna date?
.
;

/* "year"      => the year, "0000" .. "9999". */
test "Year" {
	if not date :originalzone "date" "year" "2009" {
		test_fail "failed to extract year part";
	}
}

/* "month"     => the month, "01" .. "12". */
test "Month" {
	if not date :originalzone "date" "month" "07" {
		test_fail "failed to extract month part";
	}
}

/* "day"       => the day, "01" .. "31". */
test "Day" {
	if not date :originalzone "date" "day" "20" {
		test_fail "failed to extract day part";
	}
}

/* "date"      => the date in "yyyy-mm-dd" format. */
test "Date" {
	if not date :originalzone "date" "date" "2009-07-20" {
		test_fail "failed to extract date part";
	}
}

/* "julian"    => the Modified Julian Day, that is, the date
              expressed as an integer number of days since
              00:00 UTC on November 17, 1858 (using the Gregorian
              calendar).  This corresponds to the regular
              Julian Day minus 2400000.5.  */
test "Julian" {
	if not date :originalzone "date" "julian" "55032" {
		if date :matches :originalzone "date" "julian" "*" { }
		test_fail "failed to extract julian part: ${0}";
	}
	if not date :originalzone "delivery-date" "julian" "55034" {
		if date :matches :originalzone "delivery-date" "julian" "*" { }
		test_fail "failed to extract julian part: ${0}";
	}
}

/* "hour"      => the hour, "00" .. "23". */
test "Hour" {
	if not date :originalzone "date" "hour" "21" {
		test_fail "failed to extract hour part";
	}
}

/* "minute"    => the minute, "00" .. "59". */
test "Minute" {
	if not date :originalzone "date" "minute" "44" {
		test_fail "failed to extract minute part";
	}
}

/* "second"    => the second, "00" .. "60". */
test "Second" {
	if not date :originalzone "date" "second" "43" {
		test_fail "failed to extract second part";
	}
}

/* "time"      => the time in "hh:mm:ss" format. */
test "Time" {
	if not date :originalzone "date" "time" "21:44:43" {
		test_fail "failed to extract time part";
	}
}

/* "iso8601"   => the date and time in restricted ISO 8601 format. */
test "ISO8601" {
	if not date :originalzone "date" "iso8601" "2009-07-20T21:44:43+03:00" {
		test_fail "failed to extract iso8601 part";
	}
}

/* "std11"     => the date and time in a format appropriate
                  for use in a Date: header field [RFC2822]. */
test "STD11" {
	if not date :originalzone "date" "std11" "Mon, 20 Jul 2009 21:44:43 +0300" {
		test_fail "failed to extract std11 part";
	}
}

/* "zone"      => the time zone in use.  */
test "zone" {
	if not date :originalzone "date" "zone" "+0300" {
		test_fail "failed to extract zone part";
	}

	if not date :zone "+0200" "date" "zone" "+0200" {
		test_fail "failed to extract zone part";
	}
}

/* "weekday"   => the day of the week expressed as an integer between
                  "0" and "6". "0" is Sunday, "1" is Monday, etc. */
test "Weekday" {
	if not date :originalzone "date" "weekday" "1" {
		test_fail "failed to extract weekday part";
	}
}