* test-wl-address.el: New file.
[elisp/wanderlust.git] / tests / test-wl-draft.el
1 ;; -*- lexical-binding: t -*-
2 (require 'lunit)
3 (require 'wl-draft)
4
5 (luna-define-class test-wl-draft (lunit-test-case))
6
7 (luna-define-method test-wl-draft-deduce-address-list-1 ((case test-wl-draft))
8   (lunit-assert
9    (equal
10     '("foo@example.com" "bar@example.com")
11     (with-temp-buffer
12       (insert "To: foo@example.com, bar@example.com
13 ")
14       (wl-draft-deduce-address-list (current-buffer) (point-min) (point-max))))))
15
16 (luna-define-method test-wl-draft-deduce-address-list-2 ((case test-wl-draft))
17   (lunit-assert
18    (equal
19     '("foo@example.com" "bar@example.com")
20     (with-temp-buffer
21       (insert "To: foo@example.com
22 Cc: bar@example.com
23 ")
24       (wl-draft-deduce-address-list (current-buffer) (point-min) (point-max))))))
25
26 ;; RFC 2822 A.1.2. Different types of mailboxes
27 (luna-define-method test-wl-draft-deduce-address-list-rfc2822-example-1 ((case test-wl-draft))
28   (lunit-assert
29    (equal
30     '("mary@x.test" "jdoe@example.org" "one@y.test" "boss@nil.test" "sysservices@example.net")
31     (with-temp-buffer
32       (insert "From: \"Joe Q. Public\" <john.q.public@example.com>
33 To: Mary Smith <mary@x.test>, jdoe@example.org, Who? <one@y.test>
34 Cc: <boss@nil.test>, \"Giant; \\\"Big\\\" Box\" <sysservices@example.net>
35 Date: Tue, 1 Jul 2003 10:52:37 +0200
36 Message-ID: <5678.21-Nov-1997@example.com>
37 ")
38       (wl-draft-deduce-address-list (current-buffer) (point-min) (point-max))))))
39
40 ;; RFC 2822 A.1.3. Group addresses
41 (luna-define-method test-wl-draft-deduce-address-list-rfc2822-example-2 ((case test-wl-draft))
42   (lunit-assert
43    (equal
44     '("c@a.test" "joe@where.test" "jdoe@one.test")
45     (with-temp-buffer
46       (insert "From: Pete <pete@silly.example>
47 To: A Group:Chris Jones <c@a.test>,joe@where.test,John <jdoe@one.test>;
48 Cc: Undisclosed recipients:;
49 Date: Thu, 13 Feb 1969 23:32:54 -0330
50 Message-ID: <testabcd.1234@silly.example>
51 ")
52       (wl-draft-deduce-address-list (current-buffer) (point-min) (point-max))))))
53
54 ;; RFC 2822 A.3. Resent messages
55 (luna-define-method test-wl-draft-deduce-address-list-rfc2822-example-3 ((case test-wl-draft))
56   (lunit-assert
57    (equal
58     '("j-brown@other.example")
59     (with-temp-buffer
60       (insert "Resent-From: Mary Smith <mary@example.net>
61 Resent-To: Jane Brown <j-brown@other.example>
62 Resent-Date: Mon, 24 Nov 1997 14:22:01 -0800
63 Resent-Message-ID: <78910@example.net>
64 From: John Doe <jdoe@machine.example>
65 To: Mary Smith <mary@example.net>
66 Subject: Saying Hello
67 Date: Fri, 21 Nov 1997 09:55:06 -0600
68 Message-ID: <1234@local.machine.example>
69 ")
70       (wl-draft-deduce-address-list (current-buffer) (point-min) (point-max))))))
71
72 ;; obs-phrase
73 (luna-define-method test-wl-draft-deduce-address-list-rfc2822-obs-1 ((case test-wl-draft))
74   (lunit-assert
75    (equal
76     '("foo@example.com")
77     (with-temp-buffer
78       (insert "To: foo.bar <foo@example.com>
79 ")
80       (wl-draft-deduce-address-list (current-buffer) (point-min) (point-max))))))
81
82 ;; multiple occurrences of destination address fields
83 (luna-define-method test-wl-draft-deduce-address-list-rfc2822-obs-2 ((case test-wl-draft))
84   (lunit-assert
85    (equal
86     '("foo@example.com" "bar@example.com")
87     (with-temp-buffer
88       (insert "To: foo@example.com
89 To: bar@example.com
90 ")
91       (wl-draft-deduce-address-list (current-buffer) (point-min) (point-max))))))