mirror of https://github.com/djcb/mu.git
* tests/: update test cases a bit
This commit is contained in:
parent
dbcc57baa5
commit
b416714622
|
@ -20,8 +20,8 @@ INCLUDES=$(XAPIAN_CXXFLAGS) \
|
||||||
$(GMIME_CFLAGS) \
|
$(GMIME_CFLAGS) \
|
||||||
$(GLIB_CFLAGS) \
|
$(GLIB_CFLAGS) \
|
||||||
-I ${top_srcdir} \
|
-I ${top_srcdir} \
|
||||||
-DMU_TESTMAILDIR=\"${top_srcdir}/src/tests/testdir\" \
|
-DMU_TESTMAILDIR=\"${abs_srcdir}/src/tests/testdir\" \
|
||||||
-DMU_PROGRAM=\"${top_builddir}/src//mu\" \
|
-DMU_PROGRAM=\"${abs_builddir}/src//mu\" \
|
||||||
-DABS_SRCDIR=\"${abs_srcdir}\"
|
-DABS_SRCDIR=\"${abs_srcdir}\"
|
||||||
|
|
||||||
noinst_PROGRAMS= $(TEST_PROGS)
|
noinst_PROGRAMS= $(TEST_PROGS)
|
||||||
|
|
|
@ -45,8 +45,6 @@ fill_database (void)
|
||||||
cmdline = g_strdup_printf ("%s index --muhome=%s --maildir=%s"
|
cmdline = g_strdup_printf ("%s index --muhome=%s --maildir=%s"
|
||||||
" --quiet",
|
" --quiet",
|
||||||
MU_PROGRAM, tmpdir, MU_TESTMAILDIR);
|
MU_PROGRAM, tmpdir, MU_TESTMAILDIR);
|
||||||
|
|
||||||
g_print ("[%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);
|
g_free (cmdline);
|
||||||
|
|
||||||
|
@ -85,7 +83,6 @@ test_mu_query_01 (void)
|
||||||
query = mu_query_xapian_new (xpath);
|
query = mu_query_xapian_new (xpath);
|
||||||
|
|
||||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i) {
|
for (i = 0; i != G_N_ELEMENTS(queries); ++i) {
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
MuMsgIterXapian *iter =
|
MuMsgIterXapian *iter =
|
||||||
mu_query_xapian_run (query, queries[i].query, NULL,
|
mu_query_xapian_run (query, queries[i].query, NULL,
|
||||||
|
@ -94,7 +91,6 @@ test_mu_query_01 (void)
|
||||||
if (!mu_msg_iter_xapian_is_null (iter))
|
if (!mu_msg_iter_xapian_is_null (iter))
|
||||||
do { ++count; } while (mu_msg_iter_xapian_next (iter));
|
do { ++count; } while (mu_msg_iter_xapian_next (iter));
|
||||||
|
|
||||||
g_print ("[%s][%d,%d]\n", queries[i].query,queries[i].count,count);
|
|
||||||
g_assert_cmpuint (queries[i].count, ==, count);
|
g_assert_cmpuint (queries[i].count, ==, count);
|
||||||
mu_msg_iter_xapian_destroy (iter);
|
mu_msg_iter_xapian_destroy (iter);
|
||||||
}
|
}
|
||||||
|
@ -103,6 +99,32 @@ test_mu_query_01 (void)
|
||||||
g_free (xpath);
|
g_free (xpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_mu_query_02 (void)
|
||||||
|
{
|
||||||
|
MuMsgIterXapian *iter;
|
||||||
|
MuQueryXapian *query;
|
||||||
|
const char* q;
|
||||||
|
gchar *xpath;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
xpath = fill_database ();
|
||||||
|
g_assert (xpath != NULL);
|
||||||
|
|
||||||
|
query = mu_query_xapian_new (xpath);
|
||||||
|
g_assert (query);
|
||||||
|
|
||||||
|
q = "3BE9E6535E3029448670913581E7A1A20D852173@emss35m06.us.lmco.com";
|
||||||
|
iter = mu_query_xapian_run (query, q, NULL, FALSE, 0);
|
||||||
|
g_assert (!mu_msg_iter_xapian_is_null (iter));
|
||||||
|
|
||||||
|
mu_query_xapian_destroy (query);
|
||||||
|
g_free (xpath);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -111,6 +133,11 @@ main (int argc, char *argv[])
|
||||||
/* mu_util_maildir_mkmdir */
|
/* mu_util_maildir_mkmdir */
|
||||||
g_test_add_func ("/mu-query/test-mu-query-01",
|
g_test_add_func ("/mu-query/test-mu-query-01",
|
||||||
test_mu_query_01);
|
test_mu_query_01);
|
||||||
|
/* mu_util_maildir_mkmdir */
|
||||||
|
g_test_add_func ("/mu-query/test-mu-query-02",
|
||||||
|
test_mu_query_02);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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,
|
||||||
|
|
|
@ -153,6 +153,35 @@ test_mu_util_check_dir_04 (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_mu_util_str_from_strv_01 (void)
|
||||||
|
{
|
||||||
|
const gchar *strv[] = { "aap", "noot", "mies", NULL };
|
||||||
|
gchar *str = mu_util_str_from_strv (strv);
|
||||||
|
g_assert_cmpstr (str, ==, "aap noot mies");
|
||||||
|
g_free (str);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_mu_util_str_from_strv_02 (void)
|
||||||
|
{
|
||||||
|
const gchar *strv[] = { "test", NULL };
|
||||||
|
gchar *str = mu_util_str_from_strv (strv);
|
||||||
|
g_assert_cmpstr (str, ==, "test");
|
||||||
|
g_free (str);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_mu_util_str_from_strv_03 (void)
|
||||||
|
{
|
||||||
|
const gchar *strv[] = { NULL };
|
||||||
|
gchar *str = mu_util_str_from_strv (strv);
|
||||||
|
g_assert_cmpstr (str, ==, "");
|
||||||
|
g_free (str);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -186,7 +215,14 @@ main (int argc, char *argv[])
|
||||||
test_mu_util_check_dir_03);
|
test_mu_util_check_dir_03);
|
||||||
g_test_add_func ("/mu-util/mu-util-check-dir-04",
|
g_test_add_func ("/mu-util/mu-util-check-dir-04",
|
||||||
test_mu_util_check_dir_04);
|
test_mu_util_check_dir_04);
|
||||||
|
|
||||||
|
/* test_mu_util_str_from_strv */
|
||||||
|
g_test_add_func ("/mu-util/mu-util-str-from-strv-01",
|
||||||
|
test_mu_util_str_from_strv_01);
|
||||||
|
g_test_add_func ("/mu-util/mu-util-str-from-strv-02",
|
||||||
|
test_mu_util_str_from_strv_02);
|
||||||
|
g_test_add_func ("/mu-util/mu-util-str-from-strv-03",
|
||||||
|
test_mu_util_str_from_strv_03);
|
||||||
|
|
||||||
g_log_set_handler (NULL,
|
g_log_set_handler (NULL,
|
||||||
G_LOG_LEVEL_DEBUG|
|
G_LOG_LEVEL_DEBUG|
|
||||||
|
|
Loading…
Reference in New Issue