Merge branch 'master' into emu

This commit is contained in:
Dirk-Jan C. Binnema
2011-08-16 07:32:32 +03:00

View File

@ -143,32 +143,52 @@ test_mu_threads_01 (void)
} }
struct _tinfo {
const char* threadpath;
const char *msgid;
const char* subject;
};
typedef struct _tinfo tinfo;
static void static void
test_mu_threads_rogue (void) test_mu_threads_rogue (void)
{ {
gchar *xpath; gchar *xpath;
MuMsgIter *iter; MuMsgIter *iter;
unsigned u; unsigned u;
tinfo *items;
struct {
const char* threadpath; tinfo items1 [] = {
const char *msgid;
const char* subject;
} items [] = {
{"0", "cycle0@msg.id", "cycle0"}, {"0", "cycle0@msg.id", "cycle0"},
{"0:0", "cycle0.0@msg.id", "cycle0.0"}, {"0:0", "cycle0.0@msg.id", "cycle0.0"},
{"0:0:0", "cycle0.0.0@msg.id", "cycle0.0.0"} {"0:0:0", "cycle0.0.0@msg.id", "cycle0.0.0"},
{"0:1", "rogue0@msg.id", "rogue0"},
}; };
tinfo items2 [] = {
{"0", "cycle0.0@msg.id", "cycle0.0"},
{"0:0", "cycle0@msg.id", "cycle0"},
{"0:0:0", "rogue0@msg.id", "rogue0" },
{"0:1", "cycle0.0.0@msg.id", "cycle0.0.0"}
};
xpath = fill_database (MU_TESTMAILDIR3); xpath = fill_database (MU_TESTMAILDIR3);
g_assert (xpath != NULL); g_assert (xpath != NULL);
iter = run_and_get_iter (xpath, "def"); iter = run_and_get_iter (xpath, "def");
g_assert (iter); g_assert (iter);
g_assert (!mu_msg_iter_is_done(iter)); g_assert (!mu_msg_iter_is_done(iter));
/* due to the random order in files can be indexed, there are two possible ways
* for the threads to be built-up; both are okay */
if (g_strcmp0 (mu_msg_get_msgid(mu_msg_iter_get_msg (iter, NULL)),
"cycle0@msg.id") == 0)
items = items1;
else
items = items2;
u = 0; u = 0;
while (!mu_msg_iter_is_done (iter) && u < G_N_ELEMENTS(items)) { while (!mu_msg_iter_is_done (iter) && u < G_N_ELEMENTS(items1)) {
MuMsg *msg; MuMsg *msg;
const MuMsgIterThreadInfo *ti; const MuMsgIterThreadInfo *ti;
@ -185,16 +205,16 @@ test_mu_threads_rogue (void)
/* mu_msg_get_path (msg) */ /* mu_msg_get_path (msg) */
/* ); */ /* ); */
g_assert (u < G_N_ELEMENTS(items)); g_assert (u < G_N_ELEMENTS(items1));
g_assert_cmpstr (ti->threadpath,==,items[u].threadpath); g_assert_cmpstr (ti->threadpath,==,(items)[u].threadpath);
g_assert_cmpstr (mu_msg_get_subject(msg),==,items[u].subject); g_assert_cmpstr (mu_msg_get_subject(msg),==,(items)[u].subject);
g_assert_cmpstr (mu_msg_get_msgid(msg),==,items[u].msgid); g_assert_cmpstr (mu_msg_get_msgid(msg),==,(items)[u].msgid);
++u; ++u;
mu_msg_iter_next (iter); mu_msg_iter_next (iter);
} }
g_assert (u == G_N_ELEMENTS(items)); g_assert (u == G_N_ELEMENTS(items1));
g_free (xpath); g_free (xpath);
mu_msg_iter_destroy (iter); mu_msg_iter_destroy (iter);
@ -211,7 +231,6 @@ main (int argc, char *argv[])
g_test_add_func ("/mu-query/test-mu-threads-01", test_mu_threads_01); g_test_add_func ("/mu-query/test-mu-threads-01", test_mu_threads_01);
g_test_add_func ("/mu-query/test-mu-threads-rogue", test_mu_threads_rogue); g_test_add_func ("/mu-query/test-mu-threads-rogue", test_mu_threads_rogue);
/* g_log_set_handler (NULL, */ /* g_log_set_handler (NULL, */
/* G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION, */ /* G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION, */