test: Add address cleaning tests.
authorDavid Edmondson <dme@dme.org>
Tue, 24 Jan 2012 16:14:07 +0000 (16:14 +0000)
committerDavid Bremner <bremner@debian.org>
Wed, 25 Jan 2012 11:27:01 +0000 (07:27 -0400)
test/emacs-address-cleaning.el [new file with mode: 0644]
test/emacs-address-cleaning.sh [new file with mode: 0755]
test/notmuch-test

diff --git a/test/emacs-address-cleaning.el b/test/emacs-address-cleaning.el
new file mode 100644 (file)
index 0000000..19e9e05
--- /dev/null
@@ -0,0 +1,29 @@
+(defun notmuch-test-address-cleaning-1 ()
+  (notmuch-test-expect-equal (notmuch-show-clean-address "dme@dme.org")
+                       "dme@dme.org"))
+
+(defun notmuch-test-address-cleaning-2 ()
+  (let* ((input '("foo@bar.com"
+                 "<foo@bar.com>"
+                 "Foo Bar <foo@bar.com>"
+                 "foo@bar.com <foo@bar.com>"
+                 "\"Foo Bar\" <foo@bar.com>"))
+        (expected '("foo@bar.com"
+                    "foo@bar.com"
+                    "Foo Bar <foo@bar.com>"
+                    "foo@bar.com"
+                    "Foo Bar <foo@bar.com>"))
+        (output (mapcar #'notmuch-show-clean-address input)))
+    (notmuch-test-expect-equal output expected)))
+
+(defun notmuch-test-address-cleaning-3 ()
+  (let* ((input '("ДБ <db-uknot@stop.me.uk>"
+                 "foo (at home) <foo@bar.com>"
+                 "foo [at home] <foo@bar.com>"
+                 "Foo Bar"))
+        (expected '("ДБ <db-uknot@stop.me.uk>"
+                    "foo (at home) <foo@bar.com>"
+                    "foo [at home] <foo@bar.com>"
+                    "Foo Bar"))
+        (output (mapcar #'notmuch-show-clean-address input)))
+    (notmuch-test-expect-equal output expected)))
diff --git a/test/emacs-address-cleaning.sh b/test/emacs-address-cleaning.sh
new file mode 100755 (executable)
index 0000000..0d85bdc
--- /dev/null
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+
+test_description="emacs address cleaning"
+. test-lib.sh
+
+test_begin_subtest "notmuch-test-address-clean part 1"
+test_emacs_expect_t \
+    '(load "emacs-address-cleaning.el") (notmuch-test-address-cleaning-1)'
+
+test_begin_subtest "notmuch-test-address-clean part 2"
+test_emacs_expect_t \
+    '(load "emacs-address-cleaning.el") (notmuch-test-address-cleaning-2)'
+
+test_begin_subtest "notmuch-test-address-clean part 3"
+test_subtest_known_broken
+test_emacs_expect_t \
+    '(load "emacs-address-cleaning.el") (notmuch-test-address-cleaning-3)'
+
+test_done
index d034f9979af283c87f1f76a8aa269c1434d2360f..3f1740cf73d2b68021f2c0d12bf0c86ea9391819 100755 (executable)
@@ -53,6 +53,7 @@ TESTS="
   hooks
   argument-parsing
   emacs-test-functions.sh
+  emacs-address-cleaning.sh
 "
 TESTS=${NOTMUCH_TESTS:=$TESTS}