2f1562c0aee86daf90364c11a8d9b05cc56e94ec
[elisp/wanderlust.git] / tests / test-elmo-date.el
1 (require 'lunit)
2 (require 'elmo-date)
3
4 (luna-define-class test-elmo-date (lunit-test-case))
5
6 (luna-define-method test-elmo-date-get-week ((case test-elmo-date))
7   "Check around singularity date. leap year and 2038-01-19."
8   (let ((elmo-lang "en"))
9     (lunit-assert
10      (string= "Tue" (elmo-date-get-week 2000 2 29)))
11     (lunit-assert
12      (string= "Tue" (elmo-date-get-week 2038 1 19)))
13     (lunit-assert
14      (string= "Wed" (elmo-date-get-week 2038 1 20)))
15     (lunit-assert
16      (string= "Sun" (elmo-date-get-week 2100 2 28)))
17     (lunit-assert
18      (string= "Mon" (elmo-date-get-week 2100 3 1)))))
19
20 (luna-define-method test-elmo-time-parse-date-string-1 ((case test-elmo-date))
21   ""
22   (lunit-assert
23    ;; [RFC5322] Appendix A.1.1.
24    (equal '(13429 44762)
25           (elmo-time-parse-date-string
26            "Date: Fri, 21 Nov 1997 09:55:06 -0600")))
27   (lunit-assert
28    ;; [RFC5322] Appendix A.1.2.
29    (equal '(16129 19413)
30           (elmo-time-parse-date-string
31            "Date: Tue, 1 Jul 2003 10:52:37 +0200")))
32   ;; (lunit-assert
33   ;;  ;; leapsec
34   ;;  (elmo-time-parse-date-string
35   ;;   "Date: Thu, 1 Jan 2009 08:59:60 +0900"))
36
37
38   (lunit-assert
39    ;; [RFC5322] Appendix A.1.3.
40    (equal '(-424 63838)
41           (elmo-time-parse-date-string
42            "Date: Thu, 13 Feb 1969 23:32:54 -0330")))
43 )
44
45 (luna-define-method test-elmo-time-parse-date-string-2 ((case test-elmo-date))
46   "Obsolete Date: format"
47   (lunit-assert
48    ;; [RFC5322] Appendix A.5.
49    (equal '(14403 4992)
50           (elmo-time-parse-date-string
51            (concat
52             "Date: Thu,\n"
53             "      13\n"
54             "        Feb\n"
55             "          1969\n"
56             "        23:32\n"
57             "                 -0330 (Newfoundland Time)"))))
58   (lunit-assert
59    ;; [RFC5322] Appendix A.6.2.
60    (equal '(13429 23162)
61           (elmo-time-parse-date-string
62            "Date: 21 Nov 97 09:55:06 GMT")))
63   (lunit-assert
64    ;; [RFC5322] Appendix A.6.3.
65    (equal '(13428 52452)
66           (elmo-time-parse-date-string
67            "Date  : Fri, 21 Nov 1997 09(comment):   55  :  06 -0600"))))