aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/T110-search-position-overlap-bug.sh
diff options
context:
space:
mode:
authorGravatar Tomi Ollila <tomi.ollila@iki.fi>2014-01-09 17:18:59 +0200
committerGravatar David Bremner <david@tethera.net>2014-01-13 14:16:46 -0400
commita755c9d6a9099366cc82ba3a4bee8e6d2b83d529 (patch)
treee17400d2996686722eb94404902f62043b764237 /test/T110-search-position-overlap-bug.sh
parent84719b08f757a6079f4c3331d0c476d19b265948 (diff)
test: renamed test scripts to format T\d\d\d-name.sh
All test scripts to be executed are now named as T\d\d\d-name.sh, numers in increments of 10. This eases adding new tests and developers to see which are test scripts that are executed by test suite and in which order.
Diffstat (limited to 'test/T110-search-position-overlap-bug.sh')
-rwxr-xr-xtest/T110-search-position-overlap-bug.sh37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/T110-search-position-overlap-bug.sh b/test/T110-search-position-overlap-bug.sh
new file mode 100755
index 00000000..5da6ad6f
--- /dev/null
+++ b/test/T110-search-position-overlap-bug.sh
@@ -0,0 +1,37 @@
+#!/usr/bin/env bash
+
+# Test to demonstrate a position overlap bug.
+#
+# At one point, notmuch would index terms incorrectly in the case of
+# calling index_terms multiple times for a single field. The term
+# generator was being reset to position 0 each time. This means that
+# with text such as:
+#
+# To: a@b.c, x@y.z
+#
+# one could get a bogus match by searching for:
+#
+# To: a@y.c
+#
+# Thanks to Mark Anderson for reporting the bug, (and providing a nice,
+# minimal test case that inspired what is used here), in
+# id:3wd4o8wa7fx.fsf@testarossa.amd.com
+
+test_description='that notmuch does not overlap term positions'
+. ./test-lib.sh
+
+add_message '[to]="a@b.c, x@y.z"'
+
+test_begin_subtest "Search for a@b.c matches"
+output=$(notmuch search a@b.c | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Test message #1 (inbox unread)"
+
+test_begin_subtest "Search for x@y.z matches"
+output=$(notmuch search x@y.z | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Test message #1 (inbox unread)"
+
+test_begin_subtest "Search for a@y.c must not match"
+output=$(notmuch search a@y.c | notmuch_search_sanitize)
+test_expect_equal "$output" ""
+
+test_done