[PATCH 4/4 v43] test: Add address cleaning tests.

2012-01-24 Thread David Edmondson
---
 test/emacs-address-cleaning.el |   29 +
 test/emacs-address-cleaning.sh |   19 +++
 test/notmuch-test  |1 +
 3 files changed, 49 insertions(+), 0 deletions(-)
 create mode 100644 test/emacs-address-cleaning.el
 create mode 100755 test/emacs-address-cleaning.sh

diff --git a/test/emacs-address-cleaning.el b/test/emacs-address-cleaning.el
new file mode 100644
index 000..19e9e05
--- /dev/null
+++ b/test/emacs-address-cleaning.el
@@ -0,0 +1,29 @@
+(defun notmuch-test-address-cleaning-1 ()
+  (notmuch-test-expect-equal (notmuch-show-clean-address "dme at dme.org")
+   "dme at dme.org"))
+
+(defun notmuch-test-address-cleaning-2 ()
+  (let* ((input '("foo at bar.com"
+ ""
+ "Foo Bar "
+ "foo at bar.com "
+ "\"Foo Bar\" "))
+(expected '("foo at bar.com"
+"foo at bar.com"
+"Foo Bar "
+"foo at bar.com"
+"Foo Bar "))
+(output (mapcar #'notmuch-show-clean-address input)))
+(notmuch-test-expect-equal output expected)))
+
+(defun notmuch-test-address-cleaning-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-expect-equal output expected)))
diff --git a/test/emacs-address-cleaning.sh b/test/emacs-address-cleaning.sh
new file mode 100755
index 000..0d85bdc
--- /dev/null
+++ b/test/emacs-address-cleaning.sh
@@ -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
diff --git a/test/notmuch-test b/test/notmuch-test
index d034f99..3f1740c 100755
--- a/test/notmuch-test
+++ b/test/notmuch-test
@@ -53,6 +53,7 @@ TESTS="
   hooks
   argument-parsing
   emacs-test-functions.sh
+  emacs-address-cleaning.sh
 "
 TESTS=${NOTMUCH_TESTS:=$TESTS}

-- 
1.7.8.3



[PATCH 4/4 v43] test: Add address cleaning tests.

2012-01-24 Thread David Edmondson
---
 test/emacs-address-cleaning.el |   29 +
 test/emacs-address-cleaning.sh |   19 +++
 test/notmuch-test  |1 +
 3 files changed, 49 insertions(+), 0 deletions(-)
 create mode 100644 test/emacs-address-cleaning.el
 create mode 100755 test/emacs-address-cleaning.sh

diff --git a/test/emacs-address-cleaning.el b/test/emacs-address-cleaning.el
new file mode 100644
index 000..19e9e05
--- /dev/null
+++ b/test/emacs-address-cleaning.el
@@ -0,0 +1,29 @@
+(defun notmuch-test-address-cleaning-1 ()
+  (notmuch-test-expect-equal (notmuch-show-clean-address d...@dme.org)
+   d...@dme.org))
+
+(defun notmuch-test-address-cleaning-2 ()
+  (let* ((input '(f...@bar.com
+ f...@bar.com
+ Foo Bar f...@bar.com
+ f...@bar.com f...@bar.com
+ \Foo Bar\ f...@bar.com))
+(expected '(f...@bar.com
+f...@bar.com
+Foo Bar f...@bar.com
+f...@bar.com
+Foo Bar f...@bar.com))
+(output (mapcar #'notmuch-show-clean-address input)))
+(notmuch-test-expect-equal output expected)))
+
+(defun notmuch-test-address-cleaning-3 ()
+  (let* ((input '(ДБ db-uk...@stop.me.uk
+ foo (at home) f...@bar.com
+ foo [at home] f...@bar.com
+ Foo Bar))
+(expected '(ДБ db-uk...@stop.me.uk
+foo (at home) f...@bar.com
+foo [at home] f...@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
index 000..0d85bdc
--- /dev/null
+++ b/test/emacs-address-cleaning.sh
@@ -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
diff --git a/test/notmuch-test b/test/notmuch-test
index d034f99..3f1740c 100755
--- a/test/notmuch-test
+++ b/test/notmuch-test
@@ -53,6 +53,7 @@ TESTS=
   hooks
   argument-parsing
   emacs-test-functions.sh
+  emacs-address-cleaning.sh
 
 TESTS=${NOTMUCH_TESTS:=$TESTS}
 
-- 
1.7.8.3

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch