(require 'ert) (require 'notmuch-expr) (ert-deftest and () (should (equal "(\"valued\" AND is:unread AND from:spam@example.com)" (notmuch-expr '(and "valued" (is "unread") (from "spam@example.com")))))) (ert-deftest body () (should (equal "(body:wallace AND from:gromit)" (notmuch-expr '(and (body "wallace") (from "gromit")))))) (ert-deftest regex () (should (equal "(subject:\"/Ca+sh/\" AND NOT is:important)" (notmuch-expr '(and (subject "/Ca+sh/") (not (is "important"))))))) (ert-deftest precedence () (should (equal "(to:emacs-devel AND (NOT is:spam OR is:important))" (notmuch-expr '(and (to "emacs-devel") (or (not (is "spam")) (is "important"))))))) (ert-deftest xor () (should (equal "is:inbox XOR is:sent" (notmuch-expr '(xor (is "inbox") (is "sent")))))) (ert-deftest literal () (should (equal "(is:inbox OR from:foo)" (notmuch-expr '(or (is "inbox") (literal "from:foo")))))) (ert-deftest string () (should (equal "(is:inbox OR \"from:foo\")" (notmuch-expr '(or (is "inbox") "from:foo"))))) (ert-deftest tag-with-spaces () (should (equal "is:\"a tag\"" (notmuch-expr '(tag "a tag"))))) (ert-deftest quoted-spaces () (should (equal "subject:\"Hello there\"" (notmuch-expr '(subject "Hello there"))))) (ert-deftest quoted-backslash () (should (equal "subject:\"A celebration! \\o/ Woo.\"" (notmuch-expr '(subject "A celebration! \\o/ Woo."))))) (ert-deftest quoted-quote () (should (equal "subject:\"Gandalf: \\\"Use the force!\\\" 2001\"" (notmuch-expr '(subject "Gandalf: \"Use the force!\" 2001")))))