]> git.notmuchmail.org Git - notmuch/blob - test/search-position-overlap-bug
Add test demonstrating a position overlap bug.
[notmuch] / test / search-position-overlap-bug
1 #!/bin/bash
2
3 # Test to demonstrate a position overlap bug.
4 #    
5 # At one point, notmuch would index terms incorrectly in the case of
6 # calling index_terms multiple times for a single field. The term
7 # generator was being reset to position 0 each time. This means that
8 # with text such as:
9 #
10 #       To: a@b.c, x@y.z
11 #
12 # one could get a bogus match by searching for:
13 #
14 #       To: a@y.c
15 #    
16 # Thanks to Mark Anderson for reporting the bug, (and providing a nice,
17 # minimal test case that inspired what is used here), in
18 # id:3wd4o8wa7fx.fsf@testarossa.amd.com
19
20 test_description='that notmuch does not overlap term positions'
21 . ./test-lib.sh
22
23 add_message '[to]="a@b.c, x@y.z"'
24
25 test_begin_subtest "Search for a@b.c matches"
26 output=$(notmuch search a@b.c | notmuch_search_sanitize)
27 test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Test message #1 (inbox unread)"
28
29 test_begin_subtest "Search for x@y.z matches"
30 output=$(notmuch search x@y.z | notmuch_search_sanitize)
31 test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Test message #1 (inbox unread)"
32
33 test_begin_subtest "Search for a@y.c must not match"
34 output=$(notmuch search a@y.c | notmuch_search_sanitize)
35 test_expect_equal "$output" ""
36
37 test_done