aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2021-08-24 08:17:19 -0700
committerDavid Bremner <david@tethera.net>2021-09-04 17:07:19 -0700
commitf83cd2a05ac84ef4bf28f75c763b0688df3f4201 (patch)
tree499f73405bac25d3a786d755b827a59500a63401 /test
parenta2785c3919c56a370a7f860f4eeb93846f4a1e63 (diff)
lib/parse-sexp: support and, not, and or.
All operations and (Xapian) fields will eventually have an entry in the prefixes table. The flags field is just a placeholder for now, but will eventually distinguish between various kinds of prefixes.
Diffstat (limited to 'test')
-rwxr-xr-xtest/T081-sexpr-search.sh31
1 files changed, 28 insertions, 3 deletions
diff --git a/test/T081-sexpr-search.sh b/test/T081-sexpr-search.sh
index 4e3d755c..5e1bb18d 100755
--- a/test/T081-sexpr-search.sh
+++ b/test/T081-sexpr-search.sh
@@ -9,9 +9,34 @@ fi
add_email_corpus
-test_begin_subtest "all messages: ()"
-notmuch search '*' > EXPECTED
-notmuch search --query=sexp "()" > OUTPUT
+for query in '()' '(not)' '(and)' '(or ())' '(or (not))' '(or (and))' \
+ '(or (and) (or) (not (and)))'; do
+ test_begin_subtest "all messages: $query"
+ notmuch search '*' > EXPECTED
+ notmuch search --query=sexp "$query" > OUTPUT
+ test_expect_equal_file EXPECTED OUTPUT
+done
+
+for query in '(or)' '(not ())' '(not (not))' '(not (and))' \
+ '(not (or (and) (or) (not (and))))'; do
+ test_begin_subtest "no messages: $query"
+ notmuch search --query=sexp "$query" > OUTPUT
+ test_expect_equal_file /dev/null OUTPUT
+done
+
+test_begin_subtest "and of exact terms"
+notmuch search --query=sexp '(and "wonderful" "wizard")' | notmuch_search_sanitize > OUTPUT
+cat <<EOF > EXPECTED
+thread:XXX 2009-11-18 [1/3] Carl Worth| Jan Janak; [notmuch] What a great idea! (inbox unread)
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "or of exact terms"
+notmuch search --query=sexp '(or "php" "wizard")' | notmuch_search_sanitize > OUTPUT
+cat <<EOF > EXPECTED
+thread:XXX 2010-12-29 [1/1] François Boulogne; [aur-general] Guidelines: cp, mkdir vs install (inbox unread)
+thread:XXX 2009-11-18 [1/3] Carl Worth| Jan Janak; [notmuch] What a great idea! (inbox unread)
+EOF
test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest "single term in body"