From d1494028e7e05d844e991c3aff1d15649ecac0ac Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Sat, 20 Nov 2010 14:43:35 +0200 Subject: [PATCH] * update testcases for mu-msg-field --- src/tests/Makefile.am | 4 ++++ src/tests/test-mu-cmd.c | 2 +- src/tests/test-mu-query.c | 27 +++++++++++++++++---------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am index c3fa6abd..8468e823 100644 --- a/src/tests/Makefile.am +++ b/src/tests/Makefile.am @@ -48,6 +48,10 @@ TEST_PROGS += test-mu-maildir test_mu_maildir_SOURCES= test-mu-maildir.c test_mu_maildir_LDADD= libtestmucommon.la +TEST_PROGS += test-mu-msg-fields +test_mu_msg_fields_SOURCES= test-mu-msg-fields.c +test_mu_msg_fields_LDADD= libtestmucommon.la + TEST_PROGS += test-mu-query test_mu_query_SOURCES= test-mu-query.c dummy.cc test_mu_query_LDADD= libtestmucommon.la diff --git a/src/tests/test-mu-cmd.c b/src/tests/test-mu-cmd.c index 4d0871f0..6744324b 100644 --- a/src/tests/test-mu-cmd.c +++ b/src/tests/test-mu-cmd.c @@ -17,7 +17,7 @@ ** */ -#ifdef HAVE_CONFIG_H +#if HAVE_CONFIG_H #include "config.h" #endif /*HAVE_CONFIG_H*/ diff --git a/src/tests/test-mu-query.c b/src/tests/test-mu-query.c index 53303820..1d0ab67a 100644 --- a/src/tests/test-mu-query.c +++ b/src/tests/test-mu-query.c @@ -42,8 +42,11 @@ fill_database (void) cmdline = g_strdup_printf ("%s index --muhome=%s --maildir=%s" " --quiet", MU_PROGRAM, tmpdir, MU_TESTMAILDIR); + + /* g_printerr ("\n%s\n", cmdline); */ - g_assert (g_spawn_command_line_sync (cmdline, NULL, NULL, NULL, NULL)); + g_assert (g_spawn_command_line_sync (cmdline, NULL, NULL, + NULL, NULL)); g_free (cmdline); xpath= g_strdup_printf ("%s%c%s", tmpdir, G_DIR_SEPARATOR, "xapian"); @@ -63,10 +66,13 @@ run_and_count_matches (const char *xpath, const char *query) mquery = mu_query_new (xpath); g_assert (query); - - iter = mu_query_run (mquery, query, NULL, FALSE, 1); + + iter = mu_query_run (mquery, query, MU_MSG_FIELD_ID_NONE, + FALSE, 1); mu_query_destroy (mquery); g_assert (iter); + + /* g_printerr ("\n=> %s\n", query); */ for (count = 0; !mu_msg_iter_is_done(iter); mu_msg_iter_next(iter), ++count); @@ -100,12 +106,11 @@ test_mu_query_01 (void) { "foo:pepernoot", 0 }, { "funky", 1 }, { "fünkÿ", 1 }, - }; xpath = fill_database (); 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); g_free (xpath); @@ -135,7 +140,8 @@ test_mu_query_03 (void) QResults queries[] = { { "ploughed", 1}, - { "i:3BE9E6535E3029448670913581E7A1A20D852173@emss35m06.us.lmco.com", 1}, + { "i:3BE9E6535E3029448670913581E7A1A20D852173@" + "emss35m06.us.lmco.com", 1}, /* subsets of the words in the subject should match */ { "s:gcc include search order" , 1}, @@ -170,14 +176,14 @@ test_mu_query_04 (void) int i; QResults queries[] = { -// { "frodo@example.com", 1}, +// { "frodo@example.com", 1}, /* does not match: see mu-find (1) */ { "f:frodo@example.com", 1}, { "f:Frodo Baggins", 1}, -// { "bilbo@anotherexample.com", 1}, +// { "bilbo@anotherexample.com", 1}, /* same things */ { "t:bilbo@anotherexample.com", 1}, { "t:bilbo", 1}, { "f:bilbo", 0}, - { "baggins", 1} + { "baggins", 1} }; xpath = fill_database (); @@ -203,7 +209,8 @@ test_mu_query_05 (void) g_assert (xpath != NULL); query = mu_query_new (xpath); - iter = mu_query_run (query, "fünkÿ", NULL, FALSE, 1); + iter = mu_query_run (query, "fünkÿ", MU_MSG_FIELD_ID_NONE, + FALSE, 1); msg = mu_msg_iter_get_msg (iter); g_assert_cmpstr (mu_msg_get_subject(msg),==,