summaryrefslogtreecommitdiffstats
path: root/pigeonhole/tests/extensions/date/date-parts.svtest
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:51:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:51:24 +0000
commitf7548d6d28c313cf80e6f3ef89aed16a19815df1 (patch)
treea3f6f2a3f247293bee59ecd28e8cd8ceb6ca064a /pigeonhole/tests/extensions/date/date-parts.svtest
parentInitial commit. (diff)
downloaddovecot-upstream.tar.xz
dovecot-upstream.zip
Adding upstream version 1:2.3.19.1+dfsg1.upstream/1%2.3.19.1+dfsg1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'pigeonhole/tests/extensions/date/date-parts.svtest')
-rw-r--r--pigeonhole/tests/extensions/date/date-parts.svtest120
1 files changed, 120 insertions, 0 deletions
diff --git a/pigeonhole/tests/extensions/date/date-parts.svtest b/pigeonhole/tests/extensions/date/date-parts.svtest
new file mode 100644
index 0000000..edc565c
--- /dev/null
+++ b/pigeonhole/tests/extensions/date/date-parts.svtest
@@ -0,0 +1,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";
+ }
+}