* fix: shortcut for signed is 'z', not 's'; add some unit tests as well
This commit is contained in:
@ -156,6 +156,9 @@ attachment:
|
|||||||
$ mu find flag:signed flag:attach
|
$ mu find flag:signed flag:attach
|
||||||
.fi
|
.fi
|
||||||
|
|
||||||
|
Encrypted messages may be signed as well, but this is only visible after
|
||||||
|
decrypting, and thus, is invisible to \fBmu\fR.
|
||||||
|
|
||||||
The message-priority has three possible values: low, normal or high. We can
|
The message-priority has three possible values: low, normal or high. We can
|
||||||
match them using \fBprio:\fR - for example, to get all high-priority messages
|
match them using \fBprio:\fR - for example, to get all high-priority messages
|
||||||
with a subject containing some bird:
|
with a subject containing some bird:
|
||||||
|
|||||||
@ -40,7 +40,7 @@ static const FlagInfo FLAG_INFO[] = {
|
|||||||
|
|
||||||
{ MU_FLAG_NEW, 'N', "new", MU_FLAG_TYPE_MAILDIR },
|
{ MU_FLAG_NEW, 'N', "new", MU_FLAG_TYPE_MAILDIR },
|
||||||
|
|
||||||
{ MU_FLAG_SIGNED, 's', "signed", MU_FLAG_TYPE_CONTENT },
|
{ MU_FLAG_SIGNED, 'z', "signed", MU_FLAG_TYPE_CONTENT },
|
||||||
{ MU_FLAG_ENCRYPTED, 'x', "encrypted", MU_FLAG_TYPE_CONTENT },
|
{ MU_FLAG_ENCRYPTED, 'x', "encrypted", MU_FLAG_TYPE_CONTENT },
|
||||||
{ MU_FLAG_HAS_ATTACH, 'a', "attach", MU_FLAG_TYPE_CONTENT },
|
{ MU_FLAG_HAS_ATTACH, 'a', "attach", MU_FLAG_TYPE_CONTENT },
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ mu_flag_char (MuFlags flag)
|
|||||||
|
|
||||||
case MU_FLAG_NEW: return 'N';
|
case MU_FLAG_NEW: return 'N';
|
||||||
|
|
||||||
case MU_FLAG_SIGNED: return 's';
|
case MU_FLAG_SIGNED: return 'z';
|
||||||
case MU_FLAG_ENCRYPTED: return 'x';
|
case MU_FLAG_ENCRYPTED: return 'x';
|
||||||
case MU_FLAG_HAS_ATTACH: return 'a';
|
case MU_FLAG_HAS_ATTACH: return 'a';
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ mu_flag_from_char (char kar)
|
|||||||
|
|
||||||
case 'N': return MU_FLAG_NEW;
|
case 'N': return MU_FLAG_NEW;
|
||||||
|
|
||||||
case 's': return MU_FLAG_SIGNED;
|
case 'z': return MU_FLAG_SIGNED;
|
||||||
case 'x': return MU_FLAG_ENCRYPTED;
|
case 'x': return MU_FLAG_ENCRYPTED;
|
||||||
case 'a': return MU_FLAG_HAS_ATTACH;
|
case 'a': return MU_FLAG_HAS_ATTACH;
|
||||||
|
|
||||||
@ -228,5 +228,3 @@ error:
|
|||||||
return MU_FLAG_INVALID;
|
return MU_FLAG_INVALID;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -92,7 +92,7 @@ add_synonym_for_flag (MuFlags flag, Xapian::WritableDatabase *db)
|
|||||||
|
|
||||||
db->clear_synonyms (pfx + mu_flag_name (flag));
|
db->clear_synonyms (pfx + mu_flag_name (flag));
|
||||||
db->add_synonym (pfx + mu_flag_name (flag), pfx +
|
db->add_synonym (pfx + mu_flag_name (flag), pfx +
|
||||||
(std::string(1, tolower(mu_flag_char (flag)))));
|
(std::string(1, (char)(tolower(mu_flag_char(flag))))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -219,7 +219,6 @@ flag_val (char flagchar)
|
|||||||
{
|
{
|
||||||
static const std::string
|
static const std::string
|
||||||
pfx (prefix(MU_MSG_FIELD_ID_FLAGS)),
|
pfx (prefix(MU_MSG_FIELD_ID_FLAGS)),
|
||||||
/* xapian wants lowercase */
|
|
||||||
draftstr (pfx + (char)tolower(mu_flag_char(MU_FLAG_DRAFT))),
|
draftstr (pfx + (char)tolower(mu_flag_char(MU_FLAG_DRAFT))),
|
||||||
flaggedstr (pfx + (char)tolower(mu_flag_char(MU_FLAG_FLAGGED))),
|
flaggedstr (pfx + (char)tolower(mu_flag_char(MU_FLAG_FLAGGED))),
|
||||||
passedstr (pfx + (char)tolower(mu_flag_char(MU_FLAG_PASSED))),
|
passedstr (pfx + (char)tolower(mu_flag_char(MU_FLAG_PASSED))),
|
||||||
@ -228,10 +227,10 @@ flag_val (char flagchar)
|
|||||||
trashedstr (pfx + (char)tolower(mu_flag_char(MU_FLAG_TRASHED))),
|
trashedstr (pfx + (char)tolower(mu_flag_char(MU_FLAG_TRASHED))),
|
||||||
newstr (pfx + (char)tolower(mu_flag_char(MU_FLAG_NEW))),
|
newstr (pfx + (char)tolower(mu_flag_char(MU_FLAG_NEW))),
|
||||||
|
|
||||||
signedstr (pfx + mu_flag_char(MU_FLAG_SIGNED)),
|
signedstr (pfx + (char)tolower(mu_flag_char(MU_FLAG_SIGNED))),
|
||||||
encryptedstr (pfx + mu_flag_char(MU_FLAG_ENCRYPTED)),
|
encryptedstr (pfx + (char)tolower(mu_flag_char(MU_FLAG_ENCRYPTED))),
|
||||||
has_attachstr (pfx + mu_flag_char(MU_FLAG_HAS_ATTACH)),
|
has_attachstr (pfx + (char)tolower(mu_flag_char(MU_FLAG_HAS_ATTACH))),
|
||||||
unreadstr (pfx + mu_flag_char(MU_FLAG_UNREAD));
|
unreadstr (pfx + (char)tolower(mu_flag_char(MU_FLAG_UNREAD)));
|
||||||
|
|
||||||
switch (flagchar) {
|
switch (flagchar) {
|
||||||
|
|
||||||
@ -244,7 +243,7 @@ flag_val (char flagchar)
|
|||||||
|
|
||||||
case 'N': return newstr;
|
case 'N': return newstr;
|
||||||
|
|
||||||
case 's': return signedstr;
|
case 'z': return signedstr;
|
||||||
case 'x': return encryptedstr;
|
case 'x': return encryptedstr;
|
||||||
case 'a': return has_attachstr;
|
case 'a': return has_attachstr;
|
||||||
|
|
||||||
|
|||||||
@ -126,6 +126,9 @@ EXTRA_DIST= \
|
|||||||
testdir/cur/1283599333.1840_11.cthulhu!2, \
|
testdir/cur/1283599333.1840_11.cthulhu!2, \
|
||||||
testdir/cur/1305664394.2171_402.cthulhu!2, \
|
testdir/cur/1305664394.2171_402.cthulhu!2, \
|
||||||
testdir/cur/1252168370_3.14675.cthulhu!2,S \
|
testdir/cur/1252168370_3.14675.cthulhu!2,S \
|
||||||
|
testdir/cur/signed!2,S \
|
||||||
|
testdir/cur/encrypted!2,S \
|
||||||
|
testdir/cur/signed-encrypted!2,S \
|
||||||
testdir2/bar/cur/mail1 \
|
testdir2/bar/cur/mail1 \
|
||||||
testdir2/bar/cur/mail2 \
|
testdir2/bar/cur/mail2 \
|
||||||
testdir2/bar/cur/mail3 \
|
testdir2/bar/cur/mail3 \
|
||||||
|
|||||||
@ -37,7 +37,7 @@ test_mu_flag_char (void)
|
|||||||
g_assert_cmpuint (mu_flag_char (MU_FLAG_SEEN), ==, 'S');
|
g_assert_cmpuint (mu_flag_char (MU_FLAG_SEEN), ==, 'S');
|
||||||
g_assert_cmpuint (mu_flag_char (MU_FLAG_TRASHED), ==, 'T');
|
g_assert_cmpuint (mu_flag_char (MU_FLAG_TRASHED), ==, 'T');
|
||||||
g_assert_cmpuint (mu_flag_char (MU_FLAG_NEW), ==, 'N');
|
g_assert_cmpuint (mu_flag_char (MU_FLAG_NEW), ==, 'N');
|
||||||
g_assert_cmpuint (mu_flag_char (MU_FLAG_SIGNED), ==, 's');
|
g_assert_cmpuint (mu_flag_char (MU_FLAG_SIGNED), ==, 'z');
|
||||||
g_assert_cmpuint (mu_flag_char (MU_FLAG_ENCRYPTED), ==, 'x');
|
g_assert_cmpuint (mu_flag_char (MU_FLAG_ENCRYPTED), ==, 'x');
|
||||||
g_assert_cmpuint (mu_flag_char (MU_FLAG_HAS_ATTACH), ==, 'a');
|
g_assert_cmpuint (mu_flag_char (MU_FLAG_HAS_ATTACH), ==, 'a');
|
||||||
g_assert_cmpuint (mu_flag_char (MU_FLAG_UNREAD), ==, 'u');
|
g_assert_cmpuint (mu_flag_char (MU_FLAG_UNREAD), ==, 'u');
|
||||||
@ -68,7 +68,7 @@ test_mu_flags_to_str_s (void)
|
|||||||
{
|
{
|
||||||
g_assert_cmpstr (mu_flags_to_str_s(MU_FLAG_PASSED|MU_FLAG_SIGNED,
|
g_assert_cmpstr (mu_flags_to_str_s(MU_FLAG_PASSED|MU_FLAG_SIGNED,
|
||||||
MU_FLAG_TYPE_ANY),
|
MU_FLAG_TYPE_ANY),
|
||||||
==, "Ps");
|
==, "Pz");
|
||||||
g_assert_cmpstr (mu_flags_to_str_s(MU_FLAG_NEW, MU_FLAG_TYPE_ANY),
|
g_assert_cmpstr (mu_flags_to_str_s(MU_FLAG_NEW, MU_FLAG_TYPE_ANY),
|
||||||
==, "N");
|
==, "N");
|
||||||
g_assert_cmpstr (mu_flags_to_str_s(MU_FLAG_HAS_ATTACH|MU_FLAG_TRASHED,
|
g_assert_cmpstr (mu_flags_to_str_s(MU_FLAG_HAS_ATTACH|MU_FLAG_TRASHED,
|
||||||
@ -79,7 +79,7 @@ test_mu_flags_to_str_s (void)
|
|||||||
|
|
||||||
g_assert_cmpstr (mu_flags_to_str_s(MU_FLAG_PASSED|MU_FLAG_SIGNED,
|
g_assert_cmpstr (mu_flags_to_str_s(MU_FLAG_PASSED|MU_FLAG_SIGNED,
|
||||||
MU_FLAG_TYPE_CONTENT),
|
MU_FLAG_TYPE_CONTENT),
|
||||||
==, "s");
|
==, "z");
|
||||||
|
|
||||||
g_assert_cmpstr (mu_flags_to_str_s(MU_FLAG_NEW, MU_FLAG_TYPE_MAILDIR),
|
g_assert_cmpstr (mu_flags_to_str_s(MU_FLAG_NEW, MU_FLAG_TYPE_MAILDIR),
|
||||||
==, "N");
|
==, "N");
|
||||||
@ -97,14 +97,14 @@ test_mu_flags_from_str (void)
|
|||||||
{
|
{
|
||||||
g_assert_cmpuint (mu_flags_from_str ("RP", MU_FLAG_TYPE_ANY), ==,
|
g_assert_cmpuint (mu_flags_from_str ("RP", MU_FLAG_TYPE_ANY), ==,
|
||||||
MU_FLAG_REPLIED | MU_FLAG_PASSED);
|
MU_FLAG_REPLIED | MU_FLAG_PASSED);
|
||||||
g_assert_cmpuint (mu_flags_from_str ("Ns", MU_FLAG_TYPE_ANY), ==,
|
g_assert_cmpuint (mu_flags_from_str ("Nz", MU_FLAG_TYPE_ANY), ==,
|
||||||
MU_FLAG_NEW | MU_FLAG_SIGNED);
|
MU_FLAG_NEW | MU_FLAG_SIGNED);
|
||||||
g_assert_cmpuint (mu_flags_from_str ("axD", MU_FLAG_TYPE_ANY), ==,
|
g_assert_cmpuint (mu_flags_from_str ("axD", MU_FLAG_TYPE_ANY), ==,
|
||||||
MU_FLAG_HAS_ATTACH | MU_FLAG_ENCRYPTED | MU_FLAG_DRAFT);
|
MU_FLAG_HAS_ATTACH | MU_FLAG_ENCRYPTED | MU_FLAG_DRAFT);
|
||||||
|
|
||||||
g_assert_cmpuint (mu_flags_from_str ("RP", MU_FLAG_TYPE_MAILFILE), ==,
|
g_assert_cmpuint (mu_flags_from_str ("RP", MU_FLAG_TYPE_MAILFILE), ==,
|
||||||
MU_FLAG_REPLIED | MU_FLAG_PASSED);
|
MU_FLAG_REPLIED | MU_FLAG_PASSED);
|
||||||
g_assert_cmpuint (mu_flags_from_str ("Ns", MU_FLAG_TYPE_MAILFILE), ==,
|
g_assert_cmpuint (mu_flags_from_str ("Nz", MU_FLAG_TYPE_MAILFILE), ==,
|
||||||
MU_FLAG_NONE);
|
MU_FLAG_NONE);
|
||||||
|
|
||||||
g_assert_cmpuint (mu_flags_from_str ("qwi", MU_FLAG_TYPE_MAILFILE), ==,
|
g_assert_cmpuint (mu_flags_from_str ("qwi", MU_FLAG_TYPE_MAILFILE), ==,
|
||||||
|
|||||||
@ -259,7 +259,7 @@ test_mu_maildir_walk_01 (void)
|
|||||||
&data);
|
&data);
|
||||||
|
|
||||||
g_assert_cmpuint (MU_OK, ==, rv);
|
g_assert_cmpuint (MU_OK, ==, rv);
|
||||||
g_assert_cmpuint (data._file_count, ==, 13);
|
g_assert_cmpuint (data._file_count, ==, 16);
|
||||||
|
|
||||||
g_assert_cmpuint (data._dir_entered,==, 5);
|
g_assert_cmpuint (data._dir_entered,==, 5);
|
||||||
g_assert_cmpuint (data._dir_left,==, 5);
|
g_assert_cmpuint (data._dir_left,==, 5);
|
||||||
@ -297,7 +297,7 @@ test_mu_maildir_walk_02 (void)
|
|||||||
&data);
|
&data);
|
||||||
|
|
||||||
g_assert_cmpuint (MU_OK, ==, rv);
|
g_assert_cmpuint (MU_OK, ==, rv);
|
||||||
g_assert_cmpuint (data._file_count, ==, 9);
|
g_assert_cmpuint (data._file_count, ==, 12);
|
||||||
|
|
||||||
g_assert_cmpuint (data._dir_entered,==, 4);
|
g_assert_cmpuint (data._dir_entered,==, 4);
|
||||||
g_assert_cmpuint (data._dir_left,==, 4);
|
g_assert_cmpuint (data._dir_left,==, 4);
|
||||||
|
|||||||
@ -160,7 +160,7 @@ test_mu_query_01 (void)
|
|||||||
{ "foo:pepernoot", 0 },
|
{ "foo:pepernoot", 0 },
|
||||||
{ "funky", 1 },
|
{ "funky", 1 },
|
||||||
{ "fünkÿ", 1 },
|
{ "fünkÿ", 1 },
|
||||||
{ "", 13 }
|
{ "", 16 }
|
||||||
};
|
};
|
||||||
|
|
||||||
xpath = fill_database (MU_TESTMAILDIR);
|
xpath = fill_database (MU_TESTMAILDIR);
|
||||||
@ -243,9 +243,9 @@ test_mu_query_04 (void)
|
|||||||
{ "baggins", 1},
|
{ "baggins", 1},
|
||||||
{ "prio:h", 1},
|
{ "prio:h", 1},
|
||||||
{ "prio:high", 1},
|
{ "prio:high", 1},
|
||||||
{ "prio:normal", 5},
|
{ "prio:normal", 8},
|
||||||
{ "prio:l", 7},
|
{ "prio:l", 7},
|
||||||
{ "not prio:l", 6},
|
{ "not prio:l", 9},
|
||||||
};
|
};
|
||||||
|
|
||||||
xpath = fill_database (MU_TESTMAILDIR);
|
xpath = fill_database (MU_TESTMAILDIR);
|
||||||
@ -394,11 +394,11 @@ test_mu_query_dates_helsinki (void)
|
|||||||
/* { "date:20080804..20080731", 5}, */
|
/* { "date:20080804..20080731", 5}, */
|
||||||
{ "date:20080731..20080804", 5},
|
{ "date:20080731..20080804", 5},
|
||||||
{ "date:20080731..20080804 s:gcc", 1},
|
{ "date:20080731..20080804 s:gcc", 1},
|
||||||
{ "date:200808110803..now", 1},
|
{ "date:200808110803..now", 4},
|
||||||
{ "date:200808110803..today", 1},
|
{ "date:200808110803..today", 4},
|
||||||
/* { "date:now..2008-08-11-08-03", 1}, */
|
/* { "date:now..2008-08-11-08-03", 1}, */
|
||||||
/* { "date:today..2008-08-11-08-03", 1}, */
|
/* { "date:today..2008-08-11-08-03", 1}, */
|
||||||
{ "date:200808110801..now", 1},
|
{ "date:200808110801..now", 4},
|
||||||
};
|
};
|
||||||
|
|
||||||
old_tz = set_tz ("Europe/Helsinki");
|
old_tz = set_tz ("Europe/Helsinki");
|
||||||
@ -427,11 +427,11 @@ test_mu_query_dates_sydney (void)
|
|||||||
/* { "date:20080804..20080731", 5}, */
|
/* { "date:20080804..20080731", 5}, */
|
||||||
{ "date:20080731..20080804", 5},
|
{ "date:20080731..20080804", 5},
|
||||||
{ "date:20080731..20080804 s:gcc", 1},
|
{ "date:20080731..20080804 s:gcc", 1},
|
||||||
{ "date:200808110803..now", 1},
|
{ "date:200808110803..now", 4},
|
||||||
{ "date:200808110803..today", 1},
|
{ "date:200808110803..today", 4},
|
||||||
/* { "date:now..2008-08-11-08-03", 1}, */
|
/* { "date:now..2008-08-11-08-03", 1}, */
|
||||||
/* { "date:today..2008-08-11-08-03", 1}, */
|
/* { "date:today..2008-08-11-08-03", 1}, */
|
||||||
{ "date:200808110801..now", 1},
|
{ "date:200808110801..now", 4},
|
||||||
};
|
};
|
||||||
|
|
||||||
old_tz = set_tz ("Australia/Sydney");
|
old_tz = set_tz ("Australia/Sydney");
|
||||||
@ -460,11 +460,11 @@ test_mu_query_dates_la (void)
|
|||||||
/* { "date:20080804..20080731", 5}, */
|
/* { "date:20080804..20080731", 5}, */
|
||||||
{ "date:20080731..20080804", 5},
|
{ "date:20080731..20080804", 5},
|
||||||
{ "date:20080731..20080804 s:gcc", 1},
|
{ "date:20080731..20080804 s:gcc", 1},
|
||||||
{ "date:200808110803..now", 0},
|
{ "date:200808110803..now", 3},
|
||||||
{ "date:200808110803..today", 0},
|
{ "date:200808110803..today", 3},
|
||||||
/* { "date:now..2008-08-11-08-03", 1}, */
|
/* { "date:now..2008-08-11-08-03", 1}, */
|
||||||
/* { "date:today..2008-08-11-08-03", 1}, */
|
/* { "date:today..2008-08-11-08-03", 1}, */
|
||||||
{ "date:200808110801..now", 0}, /* does not match in LA */
|
{ "date:200808110801..now", 3}, /* does not match in LA */
|
||||||
};
|
};
|
||||||
|
|
||||||
old_tz = set_tz ("America/Los_Angeles");
|
old_tz = set_tz ("America/Los_Angeles");
|
||||||
@ -490,9 +490,9 @@ test_mu_query_sizes (void)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
QResults queries[] = {
|
QResults queries[] = {
|
||||||
{ "size:0b..2m", 13},
|
{ "size:0b..2m", 16},
|
||||||
{ "size:2k..4k", 2},
|
{ "size:2k..4k", 4},
|
||||||
{ "size:2m..0b", 13}
|
{ "size:2m..0b", 16}
|
||||||
};
|
};
|
||||||
|
|
||||||
xpath = fill_database (MU_TESTMAILDIR);
|
xpath = fill_database (MU_TESTMAILDIR);
|
||||||
@ -560,6 +560,30 @@ test_mu_query_tags (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_mu_query_signed_encrypted (void)
|
||||||
|
{
|
||||||
|
gchar *xpath;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
QResults queries[] = {
|
||||||
|
{ "flag:encrypted", 2},
|
||||||
|
{ "flag:signed", 2},
|
||||||
|
};
|
||||||
|
|
||||||
|
xpath = fill_database (MU_TESTMAILDIR);
|
||||||
|
g_assert (xpath != NULL);
|
||||||
|
|
||||||
|
/* g_print ("(%s)\n", xpath); */
|
||||||
|
|
||||||
|
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||||
|
g_assert_cmpuint (run_and_count_matches (xpath, queries[i].query),
|
||||||
|
==, queries[i].count);
|
||||||
|
|
||||||
|
g_free (xpath);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_mu_query_tags_02 (void)
|
test_mu_query_tags_02 (void)
|
||||||
{
|
{
|
||||||
@ -611,7 +635,6 @@ test_mu_query_preprocess (void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -627,6 +650,9 @@ main (int argc, char *argv[])
|
|||||||
g_test_add_func ("/mu-query/test-mu-query-03", test_mu_query_03);
|
g_test_add_func ("/mu-query/test-mu-query-03", test_mu_query_03);
|
||||||
g_test_add_func ("/mu-query/test-mu-query-04", test_mu_query_04);
|
g_test_add_func ("/mu-query/test-mu-query-04", test_mu_query_04);
|
||||||
|
|
||||||
|
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-logic", test_mu_query_logic);
|
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",
|
g_test_add_func ("/mu-query/test-mu-query-accented-chars-1",
|
||||||
|
|||||||
Reference in New Issue
Block a user