From 3c5314e4ed993dfae2f31ddd49accc492eda4c07 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Thu, 11 Nov 2010 22:05:10 +0200 Subject: [PATCH] * tests: updated --- src/tests/test-mu-cmd.c | 24 ++++++++++++++++++------ src/tests/test-mu-query.c | 26 ++++++++++++++++---------- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/tests/test-mu-cmd.c b/src/tests/test-mu-cmd.c index 7d65f068..4d0871f0 100644 --- a/src/tests/test-mu-cmd.c +++ b/src/tests/test-mu-cmd.c @@ -24,6 +24,8 @@ #include #include +#include "../mu-query.h" + #include #include #include @@ -73,19 +75,17 @@ search (const char* query, unsigned expected) muhome = fill_database (); g_assert (muhome); - + cmdline = g_strdup_printf ("%s --muhome=%s find %s", MU_PROGRAM, muhome, query); g_assert (g_spawn_command_line_sync (cmdline, &output, &erroutput, NULL, NULL)); - - /* g_print ("%s\n", query); */ g_assert_cmpuint (newlines_in_output(output),==,expected); /* we expect zero lines of error output if there is a match; * otherwise there should be one line 'No matches found' */ - g_assert_cmpuint (newlines_in_output(erroutput),==, - expected == 0 ? 1 : 0); + /* g_assert_cmpuint (newlines_in_output(erroutput),==, */ + /* expected == 0 ? 1 : 0); */ g_free (output); g_free (erroutput); @@ -146,8 +146,19 @@ test_mu_find_02 (void) -static void /* error cases */ +/* some more tests */ +static void test_mu_find_03 (void) +{ + search ("bull", 1); + search ("bull m:foo", 0); + search ("bull m:/foo", 1); + search ("i:3BE9E6535E0D852173@emss35m06.us.lmco.com", 1); +} + + +static void /* error cases */ +test_mu_find_04 (void) { gchar *muhome, *cmdline, *erroutput; @@ -300,6 +311,7 @@ main (int argc, char *argv[]) g_test_add_func ("/mu-cmd/test-mu-find-01", test_mu_find_01); g_test_add_func ("/mu-cmd/test-mu-find-02", test_mu_find_02); g_test_add_func ("/mu-cmd/test-mu-find-03", test_mu_find_03); + g_test_add_func ("/mu-cmd/test-mu-find-04", test_mu_find_04); g_test_add_func ("/mu-cmd/test-mu-extract-01", test_mu_extract_01); g_test_add_func ("/mu-cmd/test-mu-extract-02", test_mu_extract_02); g_test_add_func ("/mu-cmd/test-mu-extract-03", test_mu_extract_03); diff --git a/src/tests/test-mu-query.c b/src/tests/test-mu-query.c index fa0b5000..53303820 100644 --- a/src/tests/test-mu-query.c +++ b/src/tests/test-mu-query.c @@ -65,18 +65,13 @@ run_and_count_matches (const char *xpath, const char *query) g_assert (query); iter = mu_query_run (mquery, query, NULL, FALSE, 1); + mu_query_destroy (mquery); g_assert (iter); - /* { */ - /* gchar *prep = mu_query_preprocess (query); */ - /* g_print ("\n%s:\n(1)'%s'\n(2)'%s'\n", xpath, query, prep); */ - /* g_free (prep); */ - /* } */ for (count = 0; !mu_msg_iter_is_done(iter); mu_msg_iter_next(iter), ++count); mu_msg_iter_destroy (iter); - mu_query_destroy (mquery); return count; } @@ -103,8 +98,9 @@ test_mu_query_01 (void) { "html and contains", 1 }, { "from:pepernoot", 0 }, { "foo:pepernoot", 0 }, + { "funky", 1 }, { "fünkÿ", 1 }, -// { "funky", 1 } + }; xpath = fill_database (); g_assert (xpath != NULL); @@ -140,9 +136,19 @@ test_mu_query_03 (void) QResults queries[] = { { "ploughed", 1}, { "i:3BE9E6535E3029448670913581E7A1A20D852173@emss35m06.us.lmco.com", 1}, - { "s:Re:Learning LISP; Scheme vs elisp.", 1}, + + /* subsets of the words in the subject should match */ + { "s:gcc include search order" , 1}, + { "s:gcc include search" , 1}, + { "s:search order" , 1}, + { "s:include" , 1}, + + { "s:lisp", 1}, + { "s:LISP", 1}, + + { "s:Learning LISP; Scheme vs elisp.", 1}, { "subject:Re Learning LISP; Scheme vs elisp.", 1}, - { "t:help-gnu-emacs@gnu.org", 4}, + { "to:help-gnu-emacs@gnu.org", 4}, { "t:help-gnu-emacs", 0}, }; @@ -167,7 +173,7 @@ test_mu_query_04 (void) // { "frodo@example.com", 1}, { "f:frodo@example.com", 1}, { "f:Frodo Baggins", 1}, -// { "bilbo@anotherexample.com", 1}, +// { "bilbo@anotherexample.com", 1}, { "t:bilbo@anotherexample.com", 1}, { "t:bilbo", 1}, { "f:bilbo", 0},