* update test cases for the ignoring (or checking) invalid message flag letters
This commit is contained in:
@ -95,20 +95,29 @@ test_mu_flags_to_str_s (void)
|
|||||||
static void
|
static void
|
||||||
test_mu_flags_from_str (void)
|
test_mu_flags_from_str (void)
|
||||||
{
|
{
|
||||||
g_assert_cmpuint (mu_flags_from_str ("RP", MU_FLAG_TYPE_ANY), ==,
|
/* note, the 3rd arg to mu_flags_from_str determines whether
|
||||||
|
* invalid flags will be ignored (if TRUE) or MU_FLAG_INVALID (if FALSE)
|
||||||
|
*/
|
||||||
|
|
||||||
|
g_assert_cmpuint (mu_flags_from_str ("RP", MU_FLAG_TYPE_ANY, TRUE), ==,
|
||||||
MU_FLAG_REPLIED | MU_FLAG_PASSED);
|
MU_FLAG_REPLIED | MU_FLAG_PASSED);
|
||||||
g_assert_cmpuint (mu_flags_from_str ("Nz", MU_FLAG_TYPE_ANY), ==,
|
g_assert_cmpuint (mu_flags_from_str ("Nz", MU_FLAG_TYPE_ANY, TRUE), ==,
|
||||||
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, TRUE), ==,
|
||||||
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, TRUE), ==,
|
||||||
MU_FLAG_REPLIED | MU_FLAG_PASSED);
|
MU_FLAG_REPLIED | MU_FLAG_PASSED);
|
||||||
g_assert_cmpuint (mu_flags_from_str ("Nz", MU_FLAG_TYPE_MAILFILE), ==,
|
g_assert_cmpuint (mu_flags_from_str ("Nz", MU_FLAG_TYPE_MAILFILE, TRUE), ==,
|
||||||
MU_FLAG_NONE);
|
MU_FLAG_NONE);
|
||||||
|
|
||||||
g_assert_cmpuint (mu_flags_from_str ("qwi", MU_FLAG_TYPE_MAILFILE), ==,
|
/* ignore errors or not */
|
||||||
|
g_assert_cmpuint (mu_flags_from_str ("qwi", MU_FLAG_TYPE_MAILFILE, FALSE), ==,
|
||||||
MU_FLAG_INVALID);
|
MU_FLAG_INVALID);
|
||||||
|
g_assert_cmpuint (mu_flags_from_str ("qwi", MU_FLAG_TYPE_MAILFILE, TRUE), ==,
|
||||||
|
0);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@ -198,7 +198,6 @@ test_mu_msg_04 (void)
|
|||||||
|
|
||||||
msg = mu_msg_new_from_file (MU_TESTMAILDIR4
|
msg = mu_msg_new_from_file (MU_TESTMAILDIR4
|
||||||
"/mail5", NULL, NULL);
|
"/mail5", NULL, NULL);
|
||||||
|
|
||||||
g_assert_cmpstr (mu_msg_get_to(msg),
|
g_assert_cmpstr (mu_msg_get_to(msg),
|
||||||
==, "George Custer <gac@example.com>");
|
==, "George Custer <gac@example.com>");
|
||||||
g_assert_cmpstr (mu_msg_get_subject(msg),
|
g_assert_cmpstr (mu_msg_get_subject(msg),
|
||||||
@ -209,10 +208,8 @@ test_mu_msg_04 (void)
|
|||||||
==, MU_MSG_PRIO_NORMAL);
|
==, MU_MSG_PRIO_NORMAL);
|
||||||
g_assert_cmpuint (mu_msg_get_date(msg),
|
g_assert_cmpuint (mu_msg_get_date(msg),
|
||||||
==, 0);
|
==, 0);
|
||||||
|
|
||||||
g_assert_cmpuint (mu_msg_get_flags(msg),
|
g_assert_cmpuint (mu_msg_get_flags(msg),
|
||||||
==, MU_FLAG_HAS_ATTACH|MU_FLAG_UNREAD);
|
==, MU_FLAG_HAS_ATTACH|MU_FLAG_UNREAD);
|
||||||
|
|
||||||
mu_msg_unref (msg);
|
mu_msg_unref (msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,12 +226,51 @@ test_mu_msg_multimime (void)
|
|||||||
==, "multimime");
|
==, "multimime");
|
||||||
g_assert_cmpstr (mu_msg_get_body_text(msg),
|
g_assert_cmpstr (mu_msg_get_body_text(msg),
|
||||||
==, "abcdef");
|
==, "abcdef");
|
||||||
|
g_assert_cmpuint (mu_msg_get_flags(msg),
|
||||||
|
==, MU_FLAG_FLAGGED | MU_FLAG_SEEN |
|
||||||
|
MU_FLAG_HAS_ATTACH);
|
||||||
mu_msg_unref (msg);
|
mu_msg_unref (msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_mu_msg_flags (void)
|
||||||
|
{
|
||||||
|
unsigned u;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
const char *path;
|
||||||
|
MuFlags flags;
|
||||||
|
} msgflags [] = {
|
||||||
|
{ MU_TESTMAILDIR4 "/multimime!2,FS",
|
||||||
|
MU_FLAG_FLAGGED | MU_FLAG_SEEN |
|
||||||
|
MU_FLAG_HAS_ATTACH },
|
||||||
|
{ MU_TESTMAILDIR4 "/special!2,Sabc",
|
||||||
|
MU_FLAG_SEEN }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
for (u = 0; u != G_N_ELEMENTS(msgflags); ++u) {
|
||||||
|
MuMsg *msg;
|
||||||
|
MuFlags flags;
|
||||||
|
|
||||||
|
g_assert ((msg = mu_msg_new_from_file (msgflags[u].path, NULL, NULL)));
|
||||||
|
flags = mu_msg_get_flags (msg);
|
||||||
|
|
||||||
|
if (g_test_verbose())
|
||||||
|
g_print ("=> %s [ %s, %u] <=> [ %s, %u]\n",
|
||||||
|
msgflags[u].path,
|
||||||
|
mu_flags_to_str_s(msgflags[u].flags, MU_FLAG_TYPE_ANY),
|
||||||
|
(unsigned)msgflags[u].flags,
|
||||||
|
mu_flags_to_str_s(flags, MU_FLAG_TYPE_ANY),
|
||||||
|
(unsigned)flags);
|
||||||
|
g_assert_cmpuint (flags ,==, msgflags[u].flags);
|
||||||
|
mu_msg_unref (msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_mu_msg_umlaut (void)
|
test_mu_msg_umlaut (void)
|
||||||
{
|
{
|
||||||
@ -243,7 +279,6 @@ test_mu_msg_umlaut (void)
|
|||||||
msg = mu_msg_new_from_file (MU_TESTMAILDIR4
|
msg = mu_msg_new_from_file (MU_TESTMAILDIR4
|
||||||
"/1305664394.2171_402.cthulhu!2,",
|
"/1305664394.2171_402.cthulhu!2,",
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
|
||||||
g_assert_cmpstr (mu_msg_get_to(msg),
|
g_assert_cmpstr (mu_msg_get_to(msg),
|
||||||
==, "Helmut Kröger <hk@testmu.xxx>");
|
==, "Helmut Kröger <hk@testmu.xxx>");
|
||||||
g_assert_cmpstr (mu_msg_get_subject(msg),
|
g_assert_cmpstr (mu_msg_get_subject(msg),
|
||||||
@ -301,17 +336,23 @@ test_mu_msg_references_dups (void)
|
|||||||
|
|
||||||
g_assert_cmpuint (g_slist_length ((GSList*)refs), ==, 6);
|
g_assert_cmpuint (g_slist_length ((GSList*)refs), ==, 6);
|
||||||
|
|
||||||
g_assert_cmpstr ((char*)refs->data,==, "439C1136.90504@euler.org");
|
g_assert_cmpstr ((char*)refs->data,==,
|
||||||
|
"439C1136.90504@euler.org");
|
||||||
refs = g_slist_next (refs);
|
refs = g_slist_next (refs);
|
||||||
g_assert_cmpstr ((char*)refs->data,==, "4399DD94.5070309@euler.org");
|
g_assert_cmpstr ((char*)refs->data,==,
|
||||||
|
"4399DD94.5070309@euler.org");
|
||||||
refs = g_slist_next (refs);
|
refs = g_slist_next (refs);
|
||||||
g_assert_cmpstr ((char*)refs->data,==, "20051209233303.GA13812@gauss.org");
|
g_assert_cmpstr ((char*)refs->data,==,
|
||||||
|
"20051209233303.GA13812@gauss.org");
|
||||||
refs = g_slist_next (refs);
|
refs = g_slist_next (refs);
|
||||||
g_assert_cmpstr ((char*)refs->data,==, "439B41ED.2080402@euler.org");
|
g_assert_cmpstr ((char*)refs->data,==,
|
||||||
|
"439B41ED.2080402@euler.org");
|
||||||
refs = g_slist_next (refs);
|
refs = g_slist_next (refs);
|
||||||
g_assert_cmpstr ((char*)refs->data,==, "439A1E03.3090604@euler.org");
|
g_assert_cmpstr ((char*)refs->data,==,
|
||||||
|
"439A1E03.3090604@euler.org");
|
||||||
refs = g_slist_next (refs);
|
refs = g_slist_next (refs);
|
||||||
g_assert_cmpstr ((char*)refs->data,==, "20051211184308.GB13513@gauss.org");
|
g_assert_cmpstr ((char*)refs->data,==,
|
||||||
|
"20051211184308.GB13513@gauss.org");
|
||||||
refs = g_slist_next (refs);
|
refs = g_slist_next (refs);
|
||||||
|
|
||||||
mu_msg_unref (msg);
|
mu_msg_unref (msg);
|
||||||
@ -388,14 +429,6 @@ test_mu_msg_comp_unix_programmer (void)
|
|||||||
mu_msg_unref (msg);
|
mu_msg_unref (msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static gboolean */
|
|
||||||
/* ignore_error (const char* log_domain, GLogLevelFlags log_level, const gchar* msg, */
|
|
||||||
/* gpointer user_data) */
|
|
||||||
/* { */
|
|
||||||
/* return FALSE; /\* don't abort *\/ */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -414,6 +447,10 @@ main (int argc, char *argv[])
|
|||||||
test_mu_msg_04);
|
test_mu_msg_04);
|
||||||
g_test_add_func ("/mu-msg/mu-msg-multimime",
|
g_test_add_func ("/mu-msg/mu-msg-multimime",
|
||||||
test_mu_msg_multimime);
|
test_mu_msg_multimime);
|
||||||
|
|
||||||
|
g_test_add_func ("/mu-msg/mu-msg-flags",
|
||||||
|
test_mu_msg_flags);
|
||||||
|
|
||||||
g_test_add_func ("/mu-msg/mu-msg-tags",
|
g_test_add_func ("/mu-msg/mu-msg-tags",
|
||||||
test_mu_msg_tags);
|
test_mu_msg_tags);
|
||||||
g_test_add_func ("/mu-msg/mu-msg-references",
|
g_test_add_func ("/mu-msg/mu-msg-references",
|
||||||
|
|||||||
@ -214,7 +214,7 @@ test_mu_query_03 (void)
|
|||||||
{ "subject:\"Re: Learning LISP; Scheme vs elisp.\"", 1},
|
{ "subject:\"Re: Learning LISP; Scheme vs elisp.\"", 1},
|
||||||
{ "to:help-gnu-emacs@gnu.org", 4},
|
{ "to:help-gnu-emacs@gnu.org", 4},
|
||||||
{ "t:help-gnu-emacs", 0},
|
{ "t:help-gnu-emacs", 0},
|
||||||
{ "flag:flagged", 2}
|
{ "flag:flagged", 1}
|
||||||
};
|
};
|
||||||
|
|
||||||
xpath = fill_database (MU_TESTMAILDIR);
|
xpath = fill_database (MU_TESTMAILDIR);
|
||||||
@ -560,8 +560,8 @@ test_mu_query_signed_encrypted (void)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
QResults queries[] = {
|
QResults queries[] = {
|
||||||
{ "flag:encrypted", 3},
|
{ "flag:encrypted", 2},
|
||||||
{ "flag:signed", 3},
|
{ "flag:signed", 2},
|
||||||
};
|
};
|
||||||
|
|
||||||
xpath = fill_database (MU_TESTMAILDIR);
|
xpath = fill_database (MU_TESTMAILDIR);
|
||||||
|
|||||||
Reference in New Issue
Block a user