[PATCH v3 4/9] test: add smoke tests for the date/time parser module

Jani Nikula jani at nikula.org
Wed Sep 12 14:27:21 PDT 2012


Test the date/time parser module directly. Just a small sanity test
initially.
---
 test/notmuch-test      |    1 +
 test/parse-time-string |   26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+)
 create mode 100755 test/parse-time-string

diff --git a/test/notmuch-test b/test/notmuch-test
index cc732c3..7eadfdf 100755
--- a/test/notmuch-test
+++ b/test/notmuch-test
@@ -60,6 +60,7 @@ TESTS="
   emacs-hello
   emacs-show
   missing-headers
+  parse-time-string
 "
 TESTS=${NOTMUCH_TESTS:=$TESTS}
 
diff --git a/test/parse-time-string b/test/parse-time-string
new file mode 100755
index 0000000..34b80d7
--- /dev/null
+++ b/test/parse-time-string
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+test_description="date/time parser module"
+. ./test-lib.sh
+
+# This is currently just a quick sanity/smoke test.
+
+_date ()
+{
+    date -d "$*" +%s
+}
+
+_parse_time ()
+{
+    ${TEST_DIRECTORY}/parse-time --format=%s "$*"
+}
+
+test_begin_subtest "date(1) default format without TZ code"
+test_expect_equal "$(_parse_time Fri Aug 3 23:06:06 2012)" "$(_date Fri Aug 3 23:06:06 2012)"
+
+test_begin_subtest "date(1) --rfc-2822 format"
+test_expect_equal "$(_parse_time Fri, 03 Aug 2012 23:07:46 +0100)" "$(_date Fri, 03 Aug 2012 23:07:46 +0100)"
+
+test_begin_subtest "date(1) --rfc=3339=seconds format"
+test_expect_equal "$(_parse_time 2012-08-03 23:09:37+03:00)" "$(_date 2012-08-03 23:09:37+03:00)"
+
+test_done
-- 
1.7.9.5



More information about the notmuch mailing list