--- /dev/null
+Return-Path: <dme@dme.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id A51D7431FAF\r
+ for <notmuch@notmuchmail.org>; Mon, 16 Jan 2012 08:56:00 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id hunOZzrZESlP for <notmuch@notmuchmail.org>;\r
+ Mon, 16 Jan 2012 08:55:56 -0800 (PST)\r
+Received: from mail-we0-f181.google.com (mail-we0-f181.google.com\r
+ [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 95EB4431FAE\r
+ for <notmuch@notmuchmail.org>; Mon, 16 Jan 2012 08:55:56 -0800 (PST)\r
+Received: by werb13 with SMTP id b13so8351wer.26\r
+ for <notmuch@notmuchmail.org>; Mon, 16 Jan 2012 08:55:55 -0800 (PST)\r
+Received: by 10.216.136.98 with SMTP id v76mr2497258wei.17.1326732459768;\r
+ Mon, 16 Jan 2012 08:47:39 -0800 (PST)\r
+Received: from hotblack-desiato.hh.sledj.net\r
+ (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25])\r
+ by mx.google.com with ESMTPS id gf8sm22939726wbb.11.2012.01.16.08.47.38\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Mon, 16 Jan 2012 08:47:38 -0800 (PST)\r
+Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)\r
+ id BEEE7A04F3; Mon, 16 Jan 2012 16:47:36 +0000 (GMT)\r
+From: David Edmondson <dme@dme.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/2] test: Add tests for `notmuch-show-test-clean-address'.\r
+Date: Mon, 16 Jan 2012 16:47:33 +0000\r
+Message-Id: <1326732453-23377-2-git-send-email-dme@dme.org>\r
+X-Mailer: git-send-email 1.7.7.3\r
+In-Reply-To: <1326732453-23377-1-git-send-email-dme@dme.org>\r
+References: <1326732453-23377-1-git-send-email-dme@dme.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=UTF-8\r
+Content-Transfer-Encoding: 8bit\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 16 Jan 2012 16:56:00 -0000\r
+\r
+---\r
+\r
+Add three tests. The third one currently fails.\r
+\r
+ emacs/notmuch-test.el | 87 +++++++++++++++++++++++++++++++++++++++++++++++++\r
+ test/emacs | 6 +++\r
+ 2 files changed, 93 insertions(+), 0 deletions(-)\r
+ create mode 100644 emacs/notmuch-test.el\r
+\r
+diff --git a/emacs/notmuch-test.el b/emacs/notmuch-test.el\r
+new file mode 100644\r
+index 0000000..d6cf318\r
+--- /dev/null\r
++++ b/emacs/notmuch-test.el\r
+@@ -0,0 +1,87 @@\r
++;; notmuch-test.el --- testing the emacs interface\r
++;;\r
++;; Copyright © David Edmondson\r
++;;\r
++;; This file is part of Notmuch.\r
++;;\r
++;; Notmuch is free software: you can redistribute it and/or modify it\r
++;; under the terms of the GNU General Public License as published by\r
++;; the Free Software Foundation, either version 3 of the License, or\r
++;; (at your option) any later version.\r
++;;\r
++;; Notmuch is distributed in the hope that it will be useful, but\r
++;; WITHOUT ANY WARRANTY; without even the implied warranty of\r
++;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
++;; General Public License for more details.\r
++;;\r
++;; You should have received a copy of the GNU General Public License\r
++;; along with Notmuch. If not, see <http://www.gnu.org/licenses/>.\r
++;;\r
++;; Authors: David Edmondson <dme@dme.org>\r
++\r
++(require 'cl) ;; This code is often used uncompiled.\r
++\r
++;;\r
++\r
++(defun notmuch-test-reporter (output expected)\r
++ "Report that the `output' does not match the `expected' result."\r
++ (concat "Expect:\t" (prin1-to-string expected) "\n"\r
++ "Output:\t" (prin1-to-string output) "\n"))\r
++\r
++(defun notmuch-test-unsimilar (output expected)\r
++ "`output' and `expected' are dissimilar. Show a summary of\r
++the differences, ignoring similarities."\r
++ (cond ((and (listp output)\r
++ (listp expected))\r
++ (apply #'concat (loop for o in output\r
++ for e in expected\r
++ if (not (equal o e))\r
++ collect (notmuch-test-reporter o e))))\r
++\r
++ (t\r
++ ;; Catch all case.\r
++ (notmuch-test-reporter output expected))))\r
++\r
++(defun notmuch-test-compare (output expected)\r
++ "Compare `output' with `expected'. Report any discrepencies."\r
++ (if (equal output expected)\r
++ t\r
++ (notmuch-test-unsimilar output expected)))\r
++\r
++;;\r
++\r
++;; Tests:\r
++\r
++(defun notmuch-test-clean-address-1 ()\r
++ (notmuch-test-compare (notmuch-show-clean-address "dme@dme.org")\r
++ "dme@dme.org"))\r
++\r
++(defun notmuch-test-clean-address-2 ()\r
++ (let* ((input '("foo@bar.com"\r
++ "<foo@bar.com>"\r
++ "Foo Bar <foo@bar.com>"\r
++ "foo@bar.com <foo@bar.com>"\r
++ "\"Foo Bar\" <foo@bar.com>"))\r
++ (expected '("foo@bar.com"\r
++ "foo@bar.com"\r
++ "Foo Bar <foo@bar.com>"\r
++ "foo@bar.com"\r
++ "Foo Bar <foo@bar.com>"))\r
++ (output (mapcar #'notmuch-show-clean-address input)))\r
++ (notmuch-test-compare output expected)))\r
++\r
++(defun notmuch-test-clean-address-3 ()\r
++ (let* ((input '("ДБ <db-uknot@stop.me.uk>"\r
++ "foo (at home) <foo@bar.com>"\r
++ "foo [at home] <foo@bar.com>"\r
++ "Foo Bar"))\r
++ (expected '("ДБ <db-uknot@stop.me.uk>"\r
++ "foo (at home) <foo@bar.com>"\r
++ "foo [at home] <foo@bar.com>"\r
++ "Foo Bar"))\r
++ (output (mapcar #'notmuch-show-clean-address input)))\r
++ (notmuch-test-compare output expected)))\r
++\r
++;;\r
++\r
++(provide 'notmuch-test)\r
+diff --git a/test/emacs b/test/emacs\r
+index ac47b16..3a536fb 100755\r
+--- a/test/emacs\r
++++ b/test/emacs\r
+@@ -514,4 +514,10 @@ counter=$(test_emacs \\r
+ )\r
+ test_expect_equal "$counter" 2\r
+ \r
++for i in 1 2 3; do\r
++ test_begin_subtest "notmuch-show-clean-address $i"\r
++ result=$(test_emacs '(load "notmuch-test.el") (notmuch-test-clean-address-'$i')')\r
++ test_expect_emacs_t "$result"\r
++done\r
++\r
+ test_done\r
+-- \r
+1.7.7.3\r
+\r