--- /dev/null
+Return-Path: <dmitry.kurochkin@gmail.com>\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 EA5CB429E35\r
+ for <notmuch@notmuchmail.org>; Tue, 17 Jan 2012 05:12:55 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_FROM=0.001, 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 2US1H-xAwF4F for <notmuch@notmuchmail.org>;\r
+ Tue, 17 Jan 2012 05:12:55 -0800 (PST)\r
+Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com\r
+ [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 120DA429E2F\r
+ for <notmuch@notmuchmail.org>; Tue, 17 Jan 2012 05:12:54 -0800 (PST)\r
+Received: by bkty12 with SMTP id y12so517886bkt.26\r
+ for <notmuch@notmuchmail.org>; Tue, 17 Jan 2012 05:12:53 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+ h=from:to:subject:in-reply-to:references:user-agent:date:message-id\r
+ :mime-version:content-type:content-transfer-encoding;\r
+ bh=QVmeDejrn907aMVyvcLo8AvIBWjpT3KpdVoyDwkdNhw=;\r
+ b=ZAcuF1LfH7ebvZfwaqycWox/oTp2E38zhvBVwRAacHMhsBsDPvNOTjr1uECH0bblTE\r
+ jkTflgKhHS1K4nbseX+GKLTlCFaoRAQouQmLQoUklnVc7Ehe504CMDrpSS9WUOc2iF4A\r
+ wZ4T9nV9jBKPey0w2V/ef7GRTiTSrrbF8MtcE=\r
+Received: by 10.204.151.195 with SMTP id d3mr6550908bkw.73.1326805973640;\r
+ Tue, 17 Jan 2012 05:12:53 -0800 (PST)\r
+Received: from localhost ([91.144.186.21])\r
+ by mx.google.com with ESMTPS id jt2sm47139358bkb.1.2012.01.17.05.12.52\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Tue, 17 Jan 2012 05:12:53 -0800 (PST)\r
+From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
+To: David Edmondson <dme@dme.org>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 2/4] test: Add address cleaning tests.\r
+In-Reply-To: <1326804748-8989-3-git-send-email-dme@dme.org>\r
+References: <1326804748-8989-1-git-send-email-dme@dme.org>\r
+ <1326804748-8989-3-git-send-email-dme@dme.org>\r
+User-Agent: Notmuch/0.11+73~g8a5402e (http://notmuchmail.org) Emacs/23.3.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Tue, 17 Jan 2012 17:11:58 +0400\r
+Message-ID: <87mx9m323l.fsf@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Transfer-Encoding: quoted-printable\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: Tue, 17 Jan 2012 13:12:56 -0000\r
+\r
+On Tue, 17 Jan 2012 12:52:26 +0000, David Edmondson <dme@dme.org> wrote:\r
+> Including some more test framework in test-lib.el.\r
+> ---\r
+> test/address-cleaning.el | 29 +++++++++++++++++++++++++++++\r
+> test/address-cleaning.sh | 11 +++++++++++\r
+> test/notmuch-test | 1 +\r
+> test/test-lib.el | 29 +++++++++++++++++++++++++++++\r
+> 4 files changed, 70 insertions(+), 0 deletions(-)\r
+> create mode 100644 test/address-cleaning.el\r
+> create mode 100755 test/address-cleaning.sh\r
+>=20\r
+\r
+Since test/ directory is used for all kind of tests not just Emacs\r
+UI-specific, so I think address-cleaning.* files should be\r
+emacs-address-cleaning.\r
+\r
+Regards,\r
+ Dmitry\r
+\r
+> diff --git a/test/address-cleaning.el b/test/address-cleaning.el\r
+> new file mode 100644\r
+> index 0000000..59e8d92\r
+> --- /dev/null\r
+> +++ b/test/address-cleaning.el\r
+> @@ -0,0 +1,29 @@\r
+> +(defun notmuch-test-address-cleaning-1 ()\r
+> + (notmuch-test-compare (notmuch-show-clean-address "dme@dme.org")\r
+> + "dme@dme.org"))\r
+> +\r
+> +(defun notmuch-test-address-cleaning-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-address-cleaning-3 ()\r
+> + (let* ((input '("=D0=94=D0=91 <db-uknot@stop.me.uk>"\r
+> + "foo (at home) <foo@bar.com>"\r
+> + "foo [at home] <foo@bar.com>"\r
+> + "Foo Bar"))\r
+> + (expected '("=D0=94=D0=91 <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
+> diff --git a/test/address-cleaning.sh b/test/address-cleaning.sh\r
+> new file mode 100755\r
+> index 0000000..7ec011a\r
+> --- /dev/null\r
+> +++ b/test/address-cleaning.sh\r
+> @@ -0,0 +1,11 @@\r
+> +#!/usr/bin/env bash\r
+> +\r
+> +test_description=3D"emacs address cleaning"\r
+> +. test-lib.sh\r
+> +\r
+> +for i in 1 2 3; do\r
+> + test_emacs_expect_t "notmuch-test-address-clean-$i" \\r
+> + '(load "address-cleaning.el") (notmuch-test-address-cleaning-'$i')'\r
+> +done\r
+> +\r
+> +test_done\r
+> diff --git a/test/notmuch-test b/test/notmuch-test\r
+> index d034f99..7768c32 100755\r
+> --- a/test/notmuch-test\r
+> +++ b/test/notmuch-test\r
+> @@ -53,6 +53,7 @@ TESTS=3D"\r
+> hooks\r
+> argument-parsing\r
+> emacs-test-functions.sh\r
+> + address-cleaning.sh\r
+> "\r
+> TESTS=3D${NOTMUCH_TESTS:=3D$TESTS}\r
+>=20=20\r
+> diff --git a/test/test-lib.el b/test/test-lib.el\r
+> index 3b817c3..cf8a46d 100644\r
+> --- a/test/test-lib.el\r
+> +++ b/test/test-lib.el\r
+> @@ -20,6 +20,8 @@\r
+> ;;\r
+> ;; Authors: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
+>=20=20\r
+> +(require 'cl) ;; This code is generally used uncompiled.\r
+> +\r
+> ;; `read-file-name' by default uses `completing-read' function to read\r
+> ;; user input. It does not respect `standard-input' variable which we\r
+> ;; use in tests to provide user input. So replace it with a plain\r
+> @@ -76,3 +78,30 @@ nothing."\r
+>=20=20\r
+> (add-hook-counter 'notmuch-hello-mode-hook)\r
+> (add-hook-counter 'notmuch-hello-refresh-hook)\r
+> +\r
+> +;; Functions to help when writing tests:\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
+> --=20\r
+> 1.7.7.3\r
+>=20\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r