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