mirror of https://github.com/djcb/mu.git
Add unit-test for multi-to/cc recipients
To check for the report in Issue #826.
This commit is contained in:
parent
94587ac3ac
commit
a81270583f
|
@ -113,6 +113,7 @@ EXTRA_DIST= \
|
|||
testdir/cur/signed!2,S \
|
||||
testdir/cur/signed-encrypted!2,S \
|
||||
testdir/cur/special!2,Sabc \
|
||||
testdir/cur/multirecip!2,S \
|
||||
testdir2/bar/cur/mail1 \
|
||||
testdir2/bar/cur/mail2 \
|
||||
testdir2/bar/cur/mail3 \
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** Copyright (C) 2008-2013 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||
** Copyright (C) 2008-2016 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify it
|
||||
** under the terms of the GNU General Public License as published by the
|
||||
|
@ -260,7 +260,7 @@ test_mu_maildir_walk_01 (void)
|
|||
&data);
|
||||
|
||||
g_assert_cmpuint (MU_OK, ==, rv);
|
||||
g_assert_cmpuint (data._file_count, ==, 18);
|
||||
g_assert_cmpuint (data._file_count, ==, 19);
|
||||
|
||||
g_assert_cmpuint (data._dir_entered,==, 5);
|
||||
g_assert_cmpuint (data._dir_left,==, 5);
|
||||
|
@ -298,7 +298,7 @@ test_mu_maildir_walk (void)
|
|||
&data);
|
||||
|
||||
g_assert_cmpuint (MU_OK, ==, rv);
|
||||
g_assert_cmpuint (data._file_count, ==, 14);
|
||||
g_assert_cmpuint (data._file_count, ==, 15);
|
||||
|
||||
g_assert_cmpuint (data._dir_entered,==, 4);
|
||||
g_assert_cmpuint (data._dir_left,==, 4);
|
||||
|
@ -330,7 +330,7 @@ test_mu_maildir_walk_with_noupdate (void)
|
|||
&data);
|
||||
|
||||
g_assert_cmpuint (MU_OK, ==, rv);
|
||||
g_assert_cmpuint (data._file_count, ==, 18);
|
||||
g_assert_cmpuint (data._file_count, ==, 19);
|
||||
g_assert_cmpuint (data._dir_entered,==, 5);
|
||||
g_assert_cmpuint (data._dir_left,==, 5);
|
||||
|
||||
|
@ -344,7 +344,7 @@ test_mu_maildir_walk_with_noupdate (void)
|
|||
&data);
|
||||
|
||||
g_assert_cmpuint (MU_OK, ==, rv);
|
||||
g_assert_cmpuint (data._file_count, ==, 18);
|
||||
g_assert_cmpuint (data._file_count, ==, 19);
|
||||
g_assert_cmpuint (data._dir_entered,==, 5);
|
||||
g_assert_cmpuint (data._dir_left,==, 5);
|
||||
|
||||
|
@ -362,7 +362,7 @@ test_mu_maildir_walk_with_noupdate (void)
|
|||
&data);
|
||||
|
||||
g_assert_cmpuint (MU_OK, ==, rv);
|
||||
g_assert_cmpuint (data._file_count, ==, 14);
|
||||
g_assert_cmpuint (data._file_count, ==, 15);
|
||||
|
||||
g_assert_cmpuint (data._dir_entered,==, 4);
|
||||
g_assert_cmpuint (data._dir_left,==, 4);
|
||||
|
@ -376,7 +376,7 @@ test_mu_maildir_walk_with_noupdate (void)
|
|||
&data);
|
||||
|
||||
g_assert_cmpuint (MU_OK, ==, rv);
|
||||
g_assert_cmpuint (data._file_count, ==, 18);
|
||||
g_assert_cmpuint (data._file_count, ==, 19);
|
||||
|
||||
g_assert_cmpuint (data._dir_entered,==, 5);
|
||||
g_assert_cmpuint (data._dir_left,==, 5);
|
||||
|
@ -647,7 +647,7 @@ main (int argc, char *argv[])
|
|||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
/* mu_util_maildir_mkmdir */
|
||||
g_test_add_func ("/mu-maildir/mu-maildir-mkdir-01",
|
||||
g_test_add_func ("/mu-maildir/mu-maildir-mkdir-01",
|
||||
test_mu_maildir_mkdir_01);
|
||||
g_test_add_func ("/mu-maildir/mu-maildir-mkdir-02",
|
||||
test_mu_maildir_mkdir_02);
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
Date: Thu, 15 May 2016 14:57:25 -0200
|
||||
From:
|
||||
To: a@example.com,b@example.com,c@example.com
|
||||
Cc: d@example.com,e@example.com
|
||||
Subject: test with multi to and cc
|
||||
Message-id: <3BE9E652343245@emss35m06.us.lmco.com>
|
||||
|
||||
Message with multi cc and to.
|
||||
|
||||
|
||||
|
|
@ -90,7 +90,8 @@ assert_no_dups (MuMsgIter *iter)
|
|||
|
||||
/* note: this also *moves the iter* */
|
||||
static guint
|
||||
run_and_count_matches_with_query_flags (const char *xpath, const char *query, MuQueryFlags flags)
|
||||
run_and_count_matches_with_query_flags (const char *xpath, const char *query,
|
||||
MuQueryFlags flags)
|
||||
{
|
||||
MuQuery *mquery;
|
||||
MuMsgIter *iter;
|
||||
|
@ -158,7 +159,8 @@ run_and_count_matches_with_query_flags (const char *xpath, const char *query, Mu
|
|||
static guint
|
||||
run_and_count_matches (const char *xpath, const char *query)
|
||||
{
|
||||
return run_and_count_matches_with_query_flags (xpath, query, MU_QUERY_FLAG_NONE);
|
||||
return run_and_count_matches_with_query_flags (
|
||||
xpath, query, MU_QUERY_FLAG_NONE);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
@ -191,7 +193,7 @@ test_mu_query_01 (void)
|
|||
{ "i:abcd$efgh@example.com", 1},
|
||||
};
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
g_assert_cmpuint (run_and_count_matches (DB_PATH1,
|
||||
queries[i].query),
|
||||
==, queries[i].count);
|
||||
|
@ -235,7 +237,7 @@ test_mu_query_03 (void)
|
|||
{ "flag:flagged", 1}
|
||||
};
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
g_assert_cmpuint (run_and_count_matches (DB_PATH1,
|
||||
queries[i].query),
|
||||
==, queries[i].count);
|
||||
|
@ -255,15 +257,15 @@ test_mu_query_04 (void)
|
|||
{ "t:bilbo@anotherexample.com", 1},
|
||||
{ "t:bilbo", 1},
|
||||
{ "f:bilbo", 0},
|
||||
{ "baggins", 1},
|
||||
{ "baggins", 1},
|
||||
{ "prio:h", 1},
|
||||
{ "prio:high", 1},
|
||||
{ "prio:normal", 10},
|
||||
{ "prio:normal", 11},
|
||||
{ "prio:l", 7},
|
||||
{ "not prio:l", 11},
|
||||
{ "not prio:l", 12},
|
||||
};
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
g_assert_cmpuint (run_and_count_matches (DB_PATH1,
|
||||
queries[i].query),
|
||||
==, queries[i].count);
|
||||
|
@ -285,7 +287,7 @@ test_mu_query_logic (void)
|
|||
{ "(subject:gcc OR subject:scheme) AND subject:elisp" , 1}
|
||||
};
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
g_assert_cmpuint (run_and_count_matches (DB_PATH1,
|
||||
queries[i].query),
|
||||
==, queries[i].count);
|
||||
|
@ -349,7 +351,7 @@ test_mu_query_accented_chars_02 (void)
|
|||
{ "Queensrÿche", 1}
|
||||
};
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
g_assert_cmpuint (run_and_count_matches (DB_PATH1,
|
||||
queries[i].query),
|
||||
==, queries[i].count);
|
||||
|
@ -371,7 +373,7 @@ test_mu_query_accented_chars_fraiche (void)
|
|||
{ "CREME FRAICHE", 1}
|
||||
};
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i) {
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i) {
|
||||
|
||||
if (g_test_verbose ())
|
||||
g_print ("'%s'\n", queries[i].query);
|
||||
|
@ -398,7 +400,7 @@ test_mu_query_wildcards (void)
|
|||
{ "Queen*", 1},
|
||||
};
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
g_assert_cmpuint (run_and_count_matches (DB_PATH1,
|
||||
queries[i].query),
|
||||
==, queries[i].count);
|
||||
|
@ -416,7 +418,7 @@ test_mu_query_dates_helsinki (void)
|
|||
{ "date:20080731..20080804", 5},
|
||||
{ "date:20080731..20080804 s:gcc", 1},
|
||||
{ "date:200808110803..now", 6},
|
||||
{ "date:200808110803..today", 6},
|
||||
{ "date:200808110803..today",7},
|
||||
{ "date:200808110801..now", 6}
|
||||
};
|
||||
|
||||
|
@ -425,7 +427,7 @@ test_mu_query_dates_helsinki (void)
|
|||
xpath = fill_database (MU_TESTMAILDIR);
|
||||
g_assert (xpath != NULL);
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
g_assert_cmpuint (run_and_count_matches
|
||||
(xpath, queries[i].query),
|
||||
==, queries[i].count);
|
||||
|
@ -455,7 +457,7 @@ test_mu_query_dates_sydney (void)
|
|||
xpath = fill_database (MU_TESTMAILDIR);
|
||||
g_assert (xpath != NULL);
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
g_assert_cmpuint (run_and_count_matches
|
||||
(xpath, queries[i].query),
|
||||
==, queries[i].count);
|
||||
|
@ -476,16 +478,16 @@ test_mu_query_dates_la (void)
|
|||
{ "date:20080731..20080804", 5},
|
||||
{ "date:20080731..20080804 s:gcc", 1},
|
||||
{ "date:200808110803..now", 5},
|
||||
{ "date:200808110803..today", 5},
|
||||
{ "date:200808110803..today", 6},
|
||||
{ "date:200808110801..now", 5}
|
||||
};
|
||||
};
|
||||
|
||||
old_tz = set_tz ("America/Los_Angeles");
|
||||
|
||||
xpath = fill_database (MU_TESTMAILDIR);
|
||||
g_assert (xpath != NULL);
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
g_assert_cmpuint (run_and_count_matches
|
||||
(xpath, queries[i].query),
|
||||
==, queries[i].count);
|
||||
|
@ -502,12 +504,12 @@ test_mu_query_sizes (void)
|
|||
{
|
||||
int i;
|
||||
QResults queries[] = {
|
||||
{ "size:0b..2m", 18},
|
||||
{ "size:0b..2m", 19},
|
||||
{ "size:2k..4k", 4},
|
||||
{ "size:2m..0b", 18}
|
||||
{ "size:2m..0b", 19}
|
||||
};
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
g_assert_cmpuint (run_and_count_matches (DB_PATH1,
|
||||
queries[i].query),
|
||||
==, queries[i].count);
|
||||
|
@ -525,7 +527,7 @@ test_mu_query_attach (void)
|
|||
{ "file:custer.jpg", 1}
|
||||
};
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i) {
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i) {
|
||||
if (g_test_verbose())
|
||||
g_print ("query: %s\n", queries[i].query);
|
||||
g_assert_cmpuint (run_and_count_matches (DB_PATH2,
|
||||
|
@ -550,7 +552,7 @@ test_mu_query_msgid (void)
|
|||
|
||||
};
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i) {
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i) {
|
||||
if (g_test_verbose())
|
||||
g_print ("query: %s\n", queries[i].query);
|
||||
g_assert_cmpuint (run_and_count_matches (DB_PATH2,
|
||||
|
@ -575,7 +577,7 @@ test_mu_query_tags (void)
|
|||
{ "x:\\\\backslash", 1},
|
||||
};
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
g_assert_cmpuint (run_and_count_matches (DB_PATH2,
|
||||
queries[i].query),
|
||||
==, queries[i].count);
|
||||
|
@ -593,7 +595,7 @@ test_mu_query_wom_bat (void)
|
|||
{ "\"maildir:/wom bat\"", 3},
|
||||
};
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
g_assert_cmpuint (run_and_count_matches (DB_PATH2,
|
||||
queries[i].query),
|
||||
==, queries[i].count);
|
||||
|
@ -610,13 +612,31 @@ test_mu_query_signed_encrypted (void)
|
|||
{ "flag:signed", 2},
|
||||
};
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
g_assert_cmpuint (run_and_count_matches (DB_PATH1,
|
||||
queries[i].query),
|
||||
==, queries[i].count);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_query_multi_to_cc (void)
|
||||
{
|
||||
int i;
|
||||
QResults queries[] = {
|
||||
{ "to:a@example.com", 1},
|
||||
{ "cc:d@example.com", 1},
|
||||
{ "to:b@example.com", 1},
|
||||
{ "cc:e@example.com", 1},
|
||||
{ "cc:e@example.com AND cc:d@example.com", 1},
|
||||
};
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
g_assert_cmpuint (run_and_count_matches (DB_PATH1,
|
||||
queries[i].query),
|
||||
==, queries[i].count);
|
||||
}
|
||||
|
||||
static void
|
||||
test_mu_query_tags_02 (void)
|
||||
{
|
||||
|
@ -628,7 +648,7 @@ test_mu_query_tags_02 (void)
|
|||
{ "tag:lost OR tag:operation*", 2},
|
||||
};
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i) {
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i) {
|
||||
g_assert_cmpuint (run_and_count_matches (DB_PATH2,
|
||||
queries[i].query),
|
||||
==, queries[i].count);
|
||||
|
@ -674,7 +694,7 @@ test_mu_query_preprocess (void)
|
|||
/* add more */
|
||||
};
|
||||
|
||||
for (u = 0; u != G_N_ELEMENTS(testcases); ++u) {
|
||||
for (u = 0; u != G_N_ELEMENTS(testcases); ++u) {
|
||||
gchar *prep;
|
||||
prep = mu_query_preprocess (testcases[u].expr, NULL);
|
||||
g_assert_cmpstr (prep, ==, testcases[u].expected);
|
||||
|
@ -708,7 +728,8 @@ main (int argc, char *argv[])
|
|||
|
||||
g_test_add_func ("/mu-query/test-mu-query-signed-encrypted",
|
||||
test_mu_query_signed_encrypted);
|
||||
|
||||
g_test_add_func ("/mu-query/test-mu-query-multi-to-cc",
|
||||
test_mu_query_multi_to_cc);
|
||||
g_test_add_func ("/mu-query/test-mu-query-logic", test_mu_query_logic);
|
||||
|
||||
g_test_add_func ("/mu-query/test-mu-query-accented-chars-1",
|
||||
|
|
Loading…
Reference in New Issue