1 Return-Path: <dme@dme.org>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id A51D7431FAF
\r
6 for <notmuch@notmuchmail.org>; Mon, 16 Jan 2012 08:56:00 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id hunOZzrZESlP for <notmuch@notmuchmail.org>;
\r
16 Mon, 16 Jan 2012 08:55:56 -0800 (PST)
\r
17 Received: from mail-we0-f181.google.com (mail-we0-f181.google.com
\r
18 [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 95EB4431FAE
\r
21 for <notmuch@notmuchmail.org>; Mon, 16 Jan 2012 08:55:56 -0800 (PST)
\r
22 Received: by werb13 with SMTP id b13so8351wer.26
\r
23 for <notmuch@notmuchmail.org>; Mon, 16 Jan 2012 08:55:55 -0800 (PST)
\r
24 Received: by 10.216.136.98 with SMTP id v76mr2497258wei.17.1326732459768;
\r
25 Mon, 16 Jan 2012 08:47:39 -0800 (PST)
\r
26 Received: from hotblack-desiato.hh.sledj.net
\r
27 (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25])
\r
28 by mx.google.com with ESMTPS id gf8sm22939726wbb.11.2012.01.16.08.47.38
\r
29 (version=TLSv1/SSLv3 cipher=OTHER);
\r
30 Mon, 16 Jan 2012 08:47:38 -0800 (PST)
\r
31 Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)
\r
32 id BEEE7A04F3; Mon, 16 Jan 2012 16:47:36 +0000 (GMT)
\r
33 From: David Edmondson <dme@dme.org>
\r
34 To: notmuch@notmuchmail.org
\r
35 Subject: [PATCH 2/2] test: Add tests for `notmuch-show-test-clean-address'.
\r
36 Date: Mon, 16 Jan 2012 16:47:33 +0000
\r
37 Message-Id: <1326732453-23377-2-git-send-email-dme@dme.org>
\r
38 X-Mailer: git-send-email 1.7.7.3
\r
39 In-Reply-To: <1326732453-23377-1-git-send-email-dme@dme.org>
\r
40 References: <1326732453-23377-1-git-send-email-dme@dme.org>
\r
42 Content-Type: text/plain; charset=UTF-8
\r
43 Content-Transfer-Encoding: 8bit
\r
44 X-BeenThere: notmuch@notmuchmail.org
\r
45 X-Mailman-Version: 2.1.13
\r
47 List-Id: "Use and development of the notmuch mail system."
\r
48 <notmuch.notmuchmail.org>
\r
49 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
50 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
51 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
52 List-Post: <mailto:notmuch@notmuchmail.org>
\r
53 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
54 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
55 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
56 X-List-Received-Date: Mon, 16 Jan 2012 16:56:00 -0000
\r
60 Add three tests. The third one currently fails.
\r
62 emacs/notmuch-test.el | 87 +++++++++++++++++++++++++++++++++++++++++++++++++
\r
64 2 files changed, 93 insertions(+), 0 deletions(-)
\r
65 create mode 100644 emacs/notmuch-test.el
\r
67 diff --git a/emacs/notmuch-test.el b/emacs/notmuch-test.el
\r
68 new file mode 100644
\r
69 index 0000000..d6cf318
\r
71 +++ b/emacs/notmuch-test.el
\r
73 +;; notmuch-test.el --- testing the emacs interface
\r
75 +;; Copyright © David Edmondson
\r
77 +;; This file is part of Notmuch.
\r
79 +;; Notmuch is free software: you can redistribute it and/or modify it
\r
80 +;; under the terms of the GNU General Public License as published by
\r
81 +;; the Free Software Foundation, either version 3 of the License, or
\r
82 +;; (at your option) any later version.
\r
84 +;; Notmuch is distributed in the hope that it will be useful, but
\r
85 +;; WITHOUT ANY WARRANTY; without even the implied warranty of
\r
86 +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
87 +;; General Public License for more details.
\r
89 +;; You should have received a copy of the GNU General Public License
\r
90 +;; along with Notmuch. If not, see <http://www.gnu.org/licenses/>.
\r
92 +;; Authors: David Edmondson <dme@dme.org>
\r
94 +(require 'cl) ;; This code is often used uncompiled.
\r
98 +(defun notmuch-test-reporter (output expected)
\r
99 + "Report that the `output' does not match the `expected' result."
\r
100 + (concat "Expect:\t" (prin1-to-string expected) "\n"
\r
101 + "Output:\t" (prin1-to-string output) "\n"))
\r
103 +(defun notmuch-test-unsimilar (output expected)
\r
104 + "`output' and `expected' are dissimilar. Show a summary of
\r
105 +the differences, ignoring similarities."
\r
106 + (cond ((and (listp output)
\r
107 + (listp expected))
\r
108 + (apply #'concat (loop for o in output
\r
109 + for e in expected
\r
110 + if (not (equal o e))
\r
111 + collect (notmuch-test-reporter o e))))
\r
114 + ;; Catch all case.
\r
115 + (notmuch-test-reporter output expected))))
\r
117 +(defun notmuch-test-compare (output expected)
\r
118 + "Compare `output' with `expected'. Report any discrepencies."
\r
119 + (if (equal output expected)
\r
121 + (notmuch-test-unsimilar output expected)))
\r
127 +(defun notmuch-test-clean-address-1 ()
\r
128 + (notmuch-test-compare (notmuch-show-clean-address "dme@dme.org")
\r
131 +(defun notmuch-test-clean-address-2 ()
\r
132 + (let* ((input '("foo@bar.com"
\r
134 + "Foo Bar <foo@bar.com>"
\r
135 + "foo@bar.com <foo@bar.com>"
\r
136 + "\"Foo Bar\" <foo@bar.com>"))
\r
137 + (expected '("foo@bar.com"
\r
139 + "Foo Bar <foo@bar.com>"
\r
141 + "Foo Bar <foo@bar.com>"))
\r
142 + (output (mapcar #'notmuch-show-clean-address input)))
\r
143 + (notmuch-test-compare output expected)))
\r
145 +(defun notmuch-test-clean-address-3 ()
\r
146 + (let* ((input '("ДБ <db-uknot@stop.me.uk>"
\r
147 + "foo (at home) <foo@bar.com>"
\r
148 + "foo [at home] <foo@bar.com>"
\r
150 + (expected '("ДБ <db-uknot@stop.me.uk>"
\r
151 + "foo (at home) <foo@bar.com>"
\r
152 + "foo [at home] <foo@bar.com>"
\r
154 + (output (mapcar #'notmuch-show-clean-address input)))
\r
155 + (notmuch-test-compare output expected)))
\r
159 +(provide 'notmuch-test)
\r
160 diff --git a/test/emacs b/test/emacs
\r
161 index ac47b16..3a536fb 100755
\r
164 @@ -514,4 +514,10 @@ counter=$(test_emacs \
\r
166 test_expect_equal "$counter" 2
\r
168 +for i in 1 2 3; do
\r
169 + test_begin_subtest "notmuch-show-clean-address $i"
\r
170 + result=$(test_emacs '(load "notmuch-test.el") (notmuch-test-clean-address-'$i')')
\r
171 + test_expect_emacs_t "$result"
\r