test-mail-search-args-simplify.c revision fb79b36eb34532dbe67caf99eefe3660b8c841e0
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen/* Copyright (c) 2015 Dovecot authors, see the included COPYING file */
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen { "( ( TEXT foo ) ( TEXT bar ) )", "TEXT foo TEXT bar" },
af1f4b17a92ca7b2661737e65c7849df289d3070Timo Sirainen { "OR ( TEXT foo ) ( TEXT bar )", "(OR TEXT foo TEXT bar)" },
af1f4b17a92ca7b2661737e65c7849df289d3070Timo Sirainen { "OR ( TEXT foo ) OR ( TEXT bar ) ( TEXT baz )",
01cbf4ac5d44137ab434791be7f838d98d0fcf3bTimo Sirainen "(OR TEXT foo OR TEXT bar TEXT baz)" },
f1901fd21906911f7be075c965ac882f6a87b4c3Timo Sirainen { "OR ( ( TEXT foo TEXT foo2 ) ) ( ( TEXT bar ( TEXT baz ) ) )",
f1901fd21906911f7be075c965ac882f6a87b4c3Timo Sirainen "(OR (TEXT foo TEXT foo2) (TEXT bar TEXT baz))" },
992a13add4eea0810e4db0f042a595dddf85536aTimo Sirainen { "NOT OR ( TEXT foo ) ( TEXT bar )", "NOT TEXT foo NOT TEXT bar" },
f1901fd21906911f7be075c965ac882f6a87b4c3Timo Sirainen { "NOT ( OR ( TEXT foo ) ( TEXT bar ) )", "NOT TEXT foo NOT TEXT bar" },
63a61b7a739ae0f3f520215137d9c50f94d0f34fTimo Sirainen { "NOT ( TEXT foo TEXT bar )", "(OR NOT TEXT foo NOT TEXT bar)" },
f1901fd21906911f7be075c965ac882f6a87b4c3Timo Sirainen { "ANSWERED FLAGGED SEEN", "(ANSWERED FLAGGED SEEN)" },
63a61b7a739ae0f3f520215137d9c50f94d0f34fTimo Sirainen { "OR ( ANSWERED FLAGGED SEEN ) DRAFT", "(OR (ANSWERED FLAGGED SEEN) (DRAFT))" },
63a61b7a739ae0f3f520215137d9c50f94d0f34fTimo Sirainen { "ANSWERED TEXT foo FLAGGED SEEN", "(ANSWERED FLAGGED SEEN) TEXT foo" },
d30da25fb6be1f1c667d93767c9194000194b618Timo Sirainen { "NOT ( ANSWERED FLAGGED SEEN )", "NOT (ANSWERED FLAGGED SEEN)" },
d30da25fb6be1f1c667d93767c9194000194b618Timo Sirainen { "OR NOT ANSWERED OR NOT FLAGGED NOT SEEN", "NOT (ANSWERED FLAGGED SEEN)" }
63a61b7a739ae0f3f520215137d9c50f94d0f34fTimo Sirainen parser = mail_search_parser_init_cmdline(t_strsplit(args, " "));
63a61b7a739ae0f3f520215137d9c50f94d0f34fTimo Sirainen if (mail_search_build(mail_search_register_get_imap(),
f1901fd21906911f7be075c965ac882f6a87b4c3Timo Sirainenstatic void test_mail_search_args_simplify(void)
f1901fd21906911f7be075c965ac882f6a87b4c3Timo Sirainen unsigned int i;
af1f4b17a92ca7b2661737e65c7849df289d3070Timo Sirainen args = test_build_search_args(tests[i].input);
f1901fd21906911f7be075c965ac882f6a87b4c3Timo Sirainen test_assert(mail_search_args_to_imap(str, args->args, &error));
f1901fd21906911f7be075c965ac882f6a87b4c3Timo Sirainen test_assert_idx(strcmp(str_c(str), tests[i].output) == 0, i);
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen static void (*test_functions[])(void) = {