mirror of https://github.com/djcb/mu.git
* update test-cases
This commit is contained in:
parent
e0c522c6a0
commit
dfcbd854f0
|
@ -115,7 +115,7 @@ test_mu_index (void)
|
|||
store = mu_store_new (xpath, NULL, NULL);
|
||||
g_assert (store);
|
||||
|
||||
g_assert_cmpuint (mu_store_count (store), ==, 7);
|
||||
g_assert_cmpuint (mu_store_count (store), ==, 8);
|
||||
mu_store_destroy (store);
|
||||
|
||||
g_free (muhome);
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include "test-mu-common.h"
|
||||
#include "src/mu-msg.h"
|
||||
#include "src/mu-str.h"
|
||||
|
||||
static gboolean
|
||||
check_contact_01 (MuMsgContact *contact, int *idx)
|
||||
|
@ -275,7 +276,8 @@ static void
|
|||
test_mu_msg_comp_unix_programmer (void)
|
||||
{
|
||||
MuMsg *msg;
|
||||
|
||||
char *refs;
|
||||
|
||||
msg = mu_msg_new_from_file (MU_TESTMAILDIR2
|
||||
"bar/cur/181736.eml", NULL, NULL);
|
||||
|
||||
|
@ -287,8 +289,9 @@ test_mu_msg_comp_unix_programmer (void)
|
|||
==, "Jimbo Foobarcuux <jimbo@slp53.sl.home>");
|
||||
g_assert_cmpstr (mu_msg_get_msgid(msg),
|
||||
==, "oktdp.42997$Te.22361@news.usenetserver.com");
|
||||
|
||||
g_assert_cmpstr (mu_msg_get_references_str(msg), ==,
|
||||
|
||||
refs = mu_str_from_list (mu_msg_get_references(msg), ',');
|
||||
g_assert_cmpstr (refs, ==,
|
||||
"e9065dac-13c1-4103-9e31-6974ca232a89@t15g2000prt.googlegroups.com,"
|
||||
"87hbblwelr.fsf@sapphire.mobileactivedefense.com,"
|
||||
"pql248-4va.ln1@wilbur.25thandClement.com,"
|
||||
|
@ -300,6 +303,7 @@ test_mu_msg_comp_unix_programmer (void)
|
|||
"tO8cp.1228$GE6.370@news.usenetserver.com,"
|
||||
"ikr6ks$nlf$1@Iltempo.Update.UU.SE,"
|
||||
"8ioh48-8mu.ln1@leafnode-msgid.gclare.org.uk");
|
||||
g_free (refs);
|
||||
|
||||
//"jimbo@slp53.sl.home (Jimbo Foobarcuux)";
|
||||
g_assert_cmpuint (mu_msg_get_prio(msg), /* 'low' */
|
||||
|
@ -333,8 +337,6 @@ main (int argc, char *argv[])
|
|||
test_mu_msg_03);
|
||||
g_test_add_func ("/mu-msg/mu-msg-04",
|
||||
test_mu_msg_04);
|
||||
g_test_add_func ("/mu-msg/mu-msg-05",
|
||||
test_mu_msg_05);
|
||||
g_test_add_func ("/mu-msg/mu-msg-tags",
|
||||
test_mu_msg_tags);
|
||||
g_test_add_func ("/mu-msg/mu-msg-umlaut",
|
||||
|
|
|
@ -58,6 +58,27 @@ fill_database (const char *testdir)
|
|||
return xpath;
|
||||
}
|
||||
|
||||
static void
|
||||
assert_no_dups (MuMsgIter *iter)
|
||||
{
|
||||
GHashTable *hash;
|
||||
|
||||
hash = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
(GDestroyNotify)g_free, NULL);
|
||||
|
||||
mu_msg_iter_reset (iter);
|
||||
while (!mu_msg_iter_is_done(iter)) {
|
||||
MuMsg *msg = mu_msg_iter_get_msg (iter, NULL);
|
||||
/* make sure there are no duplicates */
|
||||
g_assert (!g_hash_table_lookup (hash, mu_msg_get_path (msg)));
|
||||
g_hash_table_insert (hash, g_strdup (mu_msg_get_path(msg)),
|
||||
GUINT_TO_POINTER(TRUE));
|
||||
mu_msg_iter_next (iter);
|
||||
}
|
||||
mu_msg_iter_reset (iter);
|
||||
g_hash_table_destroy (hash);
|
||||
}
|
||||
|
||||
|
||||
/* note: this also *moves the iter* */
|
||||
static guint
|
||||
|
@ -66,6 +87,7 @@ run_and_count_matches (const char *xpath, const char *query)
|
|||
MuQuery *mquery;
|
||||
MuMsgIter *iter;
|
||||
guint count1, count2;
|
||||
GHashTable *hash;
|
||||
|
||||
mquery = mu_query_new (xpath, NULL);
|
||||
g_assert (query);
|
||||
|
@ -85,11 +107,18 @@ run_and_count_matches (const char *xpath, const char *query)
|
|||
mu_query_destroy (mquery);
|
||||
g_assert (iter);
|
||||
|
||||
hash = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
(GDestroyNotify)g_free, NULL);
|
||||
|
||||
assert_no_dups (iter);
|
||||
|
||||
/* run query twice, to test mu_msg_iter_reset */
|
||||
for (count1 = 0; !mu_msg_iter_is_done(iter);
|
||||
for (count1 = 0; !mu_msg_iter_is_done(iter);
|
||||
mu_msg_iter_next(iter), ++count1);
|
||||
|
||||
g_assert(mu_msg_iter_reset (iter));
|
||||
mu_msg_iter_reset (iter);
|
||||
|
||||
assert_no_dups (iter);
|
||||
|
||||
for (count2 = 0; !mu_msg_iter_is_done(iter);
|
||||
mu_msg_iter_next(iter), ++count2);
|
||||
|
@ -448,9 +477,9 @@ main (int argc, char *argv[])
|
|||
g_test_add_func ("/mu-query/test-mu-query-tags",
|
||||
test_mu_query_tags);
|
||||
|
||||
g_log_set_handler (NULL,
|
||||
G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION,
|
||||
(GLogFunc)black_hole, NULL);
|
||||
/* g_log_set_handler (NULL, */
|
||||
/* G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION, */
|
||||
/* (GLogFunc)black_hole, NULL); */
|
||||
|
||||
rv = g_test_run ();
|
||||
|
||||
|
|
Loading…
Reference in New Issue