* update test cases for other changes
This commit is contained in:
@ -116,7 +116,7 @@ test_mu_index (void)
|
|||||||
g_assert (store);
|
g_assert (store);
|
||||||
|
|
||||||
g_assert_cmpuint (mu_store_count (store), ==, 9);
|
g_assert_cmpuint (mu_store_count (store), ==, 9);
|
||||||
mu_store_destroy (store);
|
mu_store_unref (store);
|
||||||
|
|
||||||
g_free (muhome);
|
g_free (muhome);
|
||||||
g_free (xpath);
|
g_free (xpath);
|
||||||
|
|||||||
@ -34,7 +34,7 @@
|
|||||||
#include "test-mu-common.h"
|
#include "test-mu-common.h"
|
||||||
#include "src/mu-query.h"
|
#include "src/mu-query.h"
|
||||||
#include "src/mu-str.h"
|
#include "src/mu-str.h"
|
||||||
|
#include "src/mu-store.h"
|
||||||
|
|
||||||
static gchar*
|
static gchar*
|
||||||
fill_database (const char *testdir)
|
fill_database (const char *testdir)
|
||||||
@ -69,7 +69,8 @@ assert_no_dups (MuMsgIter *iter)
|
|||||||
|
|
||||||
mu_msg_iter_reset (iter);
|
mu_msg_iter_reset (iter);
|
||||||
while (!mu_msg_iter_is_done(iter)) {
|
while (!mu_msg_iter_is_done(iter)) {
|
||||||
MuMsg *msg = mu_msg_iter_get_msg (iter, NULL);
|
MuMsg *msg;
|
||||||
|
msg = mu_msg_iter_get_msg_floating (iter);
|
||||||
/* make sure there are no duplicates */
|
/* make sure there are no duplicates */
|
||||||
g_assert (!g_hash_table_lookup (hash, mu_msg_get_path (msg)));
|
g_assert (!g_hash_table_lookup (hash, mu_msg_get_path (msg)));
|
||||||
g_hash_table_insert (hash, g_strdup (mu_msg_get_path(msg)),
|
g_hash_table_insert (hash, g_strdup (mu_msg_get_path(msg)),
|
||||||
@ -87,11 +88,17 @@ run_and_count_matches (const char *xpath, const char *query)
|
|||||||
{
|
{
|
||||||
MuQuery *mquery;
|
MuQuery *mquery;
|
||||||
MuMsgIter *iter;
|
MuMsgIter *iter;
|
||||||
|
MuStore *store;
|
||||||
guint count1, count2;
|
guint count1, count2;
|
||||||
|
|
||||||
mquery = mu_query_new (xpath, NULL);
|
store = mu_store_new_read_only (xpath, NULL);
|
||||||
|
g_assert (store);
|
||||||
|
|
||||||
|
mquery = mu_query_new (store, NULL);
|
||||||
g_assert (query);
|
g_assert (query);
|
||||||
|
|
||||||
|
mu_store_unref (store);
|
||||||
|
|
||||||
/* g_printerr ("\n=>'%s'\n", query); */
|
/* g_printerr ("\n=>'%s'\n", query); */
|
||||||
|
|
||||||
/* { /\* debug *\/ */
|
/* { /\* debug *\/ */
|
||||||
@ -257,6 +264,7 @@ test_mu_query_accented_chars_01 (void)
|
|||||||
MuQuery *query;
|
MuQuery *query;
|
||||||
MuMsgIter *iter;
|
MuMsgIter *iter;
|
||||||
MuMsg *msg;
|
MuMsg *msg;
|
||||||
|
MuStore *store;
|
||||||
gchar *xpath;
|
gchar *xpath;
|
||||||
GError *err;
|
GError *err;
|
||||||
gchar *summ;
|
gchar *summ;
|
||||||
@ -264,11 +272,16 @@ test_mu_query_accented_chars_01 (void)
|
|||||||
xpath = fill_database (MU_TESTMAILDIR);
|
xpath = fill_database (MU_TESTMAILDIR);
|
||||||
g_assert (xpath != NULL);
|
g_assert (xpath != NULL);
|
||||||
|
|
||||||
query = mu_query_new (xpath, NULL);
|
store = mu_store_new_read_only (xpath, NULL);
|
||||||
|
g_assert (store);
|
||||||
|
|
||||||
|
query = mu_query_new (store, NULL);
|
||||||
|
mu_store_unref (store);
|
||||||
|
|
||||||
iter = mu_query_run (query, "fünkÿ", FALSE, MU_MSG_FIELD_ID_NONE,
|
iter = mu_query_run (query, "fünkÿ", FALSE, MU_MSG_FIELD_ID_NONE,
|
||||||
FALSE, NULL);
|
FALSE, NULL);
|
||||||
err = NULL;
|
err = NULL;
|
||||||
msg = mu_msg_iter_get_msg (iter, &err); /* don't unref */
|
msg = mu_msg_iter_get_msg_floating (iter); /* don't unref */
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
g_warning ("error getting message: %s", err->message);
|
g_warning ("error getting message: %s", err->message);
|
||||||
g_error_free (err);
|
g_error_free (err);
|
||||||
@ -585,9 +598,9 @@ main (int argc, char *argv[])
|
|||||||
g_test_add_func ("/mu-query/test-mu-query-tags_02",
|
g_test_add_func ("/mu-query/test-mu-query-tags_02",
|
||||||
test_mu_query_tags_02);
|
test_mu_query_tags_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,
|
||||||
/* (GLogFunc)black_hole, NULL); */
|
(GLogFunc)black_hole, NULL);
|
||||||
|
|
||||||
rv = g_test_run ();
|
rv = g_test_run ();
|
||||||
|
|
||||||
|
|||||||
@ -51,7 +51,7 @@ test_mu_store_new_destroy (void)
|
|||||||
g_assert_cmpuint (0,==,mu_store_count (store));
|
g_assert_cmpuint (0,==,mu_store_count (store));
|
||||||
|
|
||||||
mu_store_flush (store);
|
mu_store_flush (store);
|
||||||
mu_store_destroy (store);
|
mu_store_unref (store);
|
||||||
|
|
||||||
g_free (tmpdir);
|
g_free (tmpdir);
|
||||||
}
|
}
|
||||||
@ -70,17 +70,17 @@ test_mu_store_version (void)
|
|||||||
err = NULL;
|
err = NULL;
|
||||||
store = mu_store_new_writable (tmpdir, NULL, &err);
|
store = mu_store_new_writable (tmpdir, NULL, &err);
|
||||||
g_assert (store);
|
g_assert (store);
|
||||||
mu_store_destroy (store);
|
mu_store_unref (store);
|
||||||
store = mu_store_new_read_only (tmpdir, &err);
|
store = mu_store_new_read_only (tmpdir, &err);
|
||||||
g_assert (store);
|
g_assert (store);
|
||||||
|
|
||||||
g_assert (err == NULL);
|
g_assert (err == NULL);
|
||||||
|
|
||||||
g_assert_cmpuint (0,==,mu_store_count (store));
|
g_assert_cmpuint (0,==,mu_store_count (store));
|
||||||
g_assert_cmpstr (MU_XAPIAN_DB_VERSION,==,
|
g_assert_cmpstr (MU_STORE_SCHEMA_VERSION,==,
|
||||||
mu_store_version(store));
|
mu_store_version(store));
|
||||||
|
|
||||||
mu_store_destroy (store);
|
mu_store_unref (store);
|
||||||
g_free (tmpdir);
|
g_free (tmpdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ test_mu_store_store_msg_and_count (void)
|
|||||||
|
|
||||||
mu_msg_unref (msg);
|
mu_msg_unref (msg);
|
||||||
|
|
||||||
mu_store_destroy (store);
|
mu_store_unref (store);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ test_mu_store_store_msg_remove_and_count (void)
|
|||||||
(store,
|
(store,
|
||||||
MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,"));
|
MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,"));
|
||||||
|
|
||||||
mu_store_destroy (store);
|
mu_store_unref (store);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/
|
/* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Copyright (C) 2008-2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
** Copyright (C) 2008-2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
**
|
**
|
||||||
** This program is free software; you can redistribute it and/or modify it
|
** This program is free software; you can redistribute it and/or modify it
|
||||||
@ -15,8 +15,8 @@
|
|||||||
**
|
**
|
||||||
** You should have received a copy of the GNU General Public License
|
** You should have received a copy of the GNU General Public License
|
||||||
** along with this program; if not, write to the Free Software Foundation,
|
** along with this program; if not, write to the Free Software Foundation,
|
||||||
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
@ -38,20 +38,20 @@ static gchar*
|
|||||||
fill_database (const char *testdir)
|
fill_database (const char *testdir)
|
||||||
{
|
{
|
||||||
gchar *cmdline, *tmpdir, *xpath;
|
gchar *cmdline, *tmpdir, *xpath;
|
||||||
|
|
||||||
tmpdir = test_mu_common_get_random_tmpdir();
|
tmpdir = test_mu_common_get_random_tmpdir();
|
||||||
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, testdir);
|
MU_PROGRAM, tmpdir, testdir);
|
||||||
/* g_print ("%s\n", cmdline); */
|
/* g_print ("%s\n", cmdline); */
|
||||||
|
|
||||||
g_assert (g_spawn_command_line_sync (cmdline, NULL, NULL,
|
g_assert (g_spawn_command_line_sync (cmdline, NULL, NULL,
|
||||||
NULL, NULL));
|
NULL, NULL));
|
||||||
g_free (cmdline);
|
g_free (cmdline);
|
||||||
xpath= g_strdup_printf ("%s%c%s", tmpdir,
|
xpath= g_strdup_printf ("%s%c%s", tmpdir,
|
||||||
G_DIR_SEPARATOR, "xapian");
|
G_DIR_SEPARATOR, "xapian");
|
||||||
g_free (tmpdir);
|
g_free (tmpdir);
|
||||||
|
|
||||||
return xpath;
|
return xpath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,16 +60,21 @@ static MuMsgIter*
|
|||||||
run_and_get_iter (const char *xpath, const char *query)
|
run_and_get_iter (const char *xpath, const char *query)
|
||||||
{
|
{
|
||||||
MuQuery *mquery;
|
MuQuery *mquery;
|
||||||
|
MuStore *store;
|
||||||
MuMsgIter *iter;
|
MuMsgIter *iter;
|
||||||
|
|
||||||
mquery = mu_query_new (xpath, NULL);
|
store = mu_store_new_read_only (xpath, NULL);
|
||||||
|
g_assert (store);
|
||||||
|
|
||||||
|
mquery = mu_query_new (store, NULL);
|
||||||
|
mu_store_unref (store);
|
||||||
g_assert (query);
|
g_assert (query);
|
||||||
|
|
||||||
iter = mu_query_run (mquery, query, TRUE, MU_MSG_FIELD_ID_DATE,
|
iter = mu_query_run (mquery, query, TRUE, MU_MSG_FIELD_ID_DATE,
|
||||||
FALSE, NULL);
|
FALSE, NULL);
|
||||||
mu_query_destroy (mquery);
|
mu_query_destroy (mquery);
|
||||||
g_assert (iter);
|
g_assert (iter);
|
||||||
|
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,9 +83,9 @@ static void
|
|||||||
test_mu_threads_01 (void)
|
test_mu_threads_01 (void)
|
||||||
{
|
{
|
||||||
gchar *xpath;
|
gchar *xpath;
|
||||||
MuMsgIter *iter;
|
MuMsgIter *iter;
|
||||||
unsigned u;
|
unsigned u;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
const char* threadpath;
|
const char* threadpath;
|
||||||
const char *msgid;
|
const char *msgid;
|
||||||
@ -99,12 +104,12 @@ test_mu_threads_01 (void)
|
|||||||
|
|
||||||
/* two children of absent root 4.0 */
|
/* two children of absent root 4.0 */
|
||||||
{"4:0", "child4.0@msg.id", "Re: child 4.0"},
|
{"4:0", "child4.0@msg.id", "Re: child 4.0"},
|
||||||
{"4:1", "child4.1@msg.id", "Re: child 4.1"}
|
{"4:1", "child4.1@msg.id", "Re: child 4.1"}
|
||||||
};
|
};
|
||||||
|
|
||||||
xpath = fill_database (MU_TESTMAILDIR3);
|
xpath = fill_database (MU_TESTMAILDIR3);
|
||||||
g_assert (xpath != NULL);
|
g_assert (xpath != NULL);
|
||||||
|
|
||||||
iter = run_and_get_iter (xpath, "abc");
|
iter = run_and_get_iter (xpath, "abc");
|
||||||
g_assert (iter);
|
g_assert (iter);
|
||||||
g_assert (!mu_msg_iter_is_done(iter));
|
g_assert (!mu_msg_iter_is_done(iter));
|
||||||
@ -113,31 +118,31 @@ test_mu_threads_01 (void)
|
|||||||
while (!mu_msg_iter_is_done (iter) && u < G_N_ELEMENTS(items)) {
|
while (!mu_msg_iter_is_done (iter) && u < G_N_ELEMENTS(items)) {
|
||||||
MuMsg *msg;
|
MuMsg *msg;
|
||||||
const MuMsgIterThreadInfo *ti;
|
const MuMsgIterThreadInfo *ti;
|
||||||
|
|
||||||
ti = mu_msg_iter_get_thread_info (iter);
|
ti = mu_msg_iter_get_thread_info (iter);
|
||||||
if (!ti)
|
if (!ti)
|
||||||
g_print ("%s: thread info not found\n",
|
g_print ("%s: thread info not found for %u\n",
|
||||||
mu_msg_get_msgid(mu_msg_iter_get_msg (iter, NULL)));
|
__FUNCTION__, (unsigned)mu_msg_iter_get_docid(iter));
|
||||||
|
|
||||||
g_assert(ti);
|
g_assert(ti);
|
||||||
|
|
||||||
msg = mu_msg_iter_get_msg (iter, NULL);
|
msg = mu_msg_iter_get_msg_floating (iter);
|
||||||
|
g_assert (msg);
|
||||||
/* g_print ("%s %s %s\n", ti->threadpath, */
|
/* g_print ("%s %s %s\n", ti->threadpath, */
|
||||||
/* mu_msg_get_msgid(msg), */
|
/* mu_msg_get_msgid(msg), */
|
||||||
/* mu_msg_get_path (msg) */
|
/* mu_msg_get_path (msg) */
|
||||||
/* ); */
|
/* ); */
|
||||||
|
|
||||||
g_assert (u < G_N_ELEMENTS(items));
|
g_assert (u < G_N_ELEMENTS(items));
|
||||||
|
|
||||||
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(items));
|
||||||
|
|
||||||
g_free (xpath);
|
g_free (xpath);
|
||||||
mu_msg_iter_destroy (iter);
|
mu_msg_iter_destroy (iter);
|
||||||
}
|
}
|
||||||
@ -154,7 +159,7 @@ 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;
|
tinfo *items;
|
||||||
|
|
||||||
@ -178,10 +183,10 @@ test_mu_threads_rogue (void)
|
|||||||
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
|
/* 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 */
|
* for the threads to be built-up; both are okay */
|
||||||
if (g_strcmp0 (mu_msg_get_msgid(mu_msg_iter_get_msg (iter, NULL)),
|
if (g_strcmp0 (mu_msg_get_msgid(mu_msg_iter_get_msg_floating (iter)),
|
||||||
"cycle0@msg.id") == 0)
|
"cycle0@msg.id") == 0)
|
||||||
items = items1;
|
items = items1;
|
||||||
else
|
else
|
||||||
@ -191,31 +196,30 @@ test_mu_threads_rogue (void)
|
|||||||
while (!mu_msg_iter_is_done (iter) && u < G_N_ELEMENTS(items1)) {
|
while (!mu_msg_iter_is_done (iter) && u < G_N_ELEMENTS(items1)) {
|
||||||
MuMsg *msg;
|
MuMsg *msg;
|
||||||
const MuMsgIterThreadInfo *ti;
|
const MuMsgIterThreadInfo *ti;
|
||||||
|
|
||||||
ti = mu_msg_iter_get_thread_info (iter);
|
ti = mu_msg_iter_get_thread_info (iter);
|
||||||
if (!ti)
|
if (!ti)
|
||||||
g_print ("%s: thread info not found\n",
|
g_print ("%s: thread info not found\n",
|
||||||
mu_msg_get_msgid(mu_msg_iter_get_msg (iter, NULL)));
|
mu_msg_get_msgid(mu_msg_iter_get_msg_floating (iter)));
|
||||||
|
|
||||||
g_assert(ti);
|
g_assert(ti);
|
||||||
|
|
||||||
msg = mu_msg_iter_get_msg (iter, NULL);
|
msg = mu_msg_iter_get_msg_floating (iter); /* don't unref */
|
||||||
/* g_print ("%s %s %s\n", ti->threadpath, */
|
/* g_print ("%s %s %s\n", ti->threadpath, */
|
||||||
/* mu_msg_get_msgid(msg), */
|
/* mu_msg_get_msgid(msg), */
|
||||||
/* mu_msg_get_path (msg) */
|
/* mu_msg_get_path (msg) */
|
||||||
/* ); */
|
/* ); */
|
||||||
|
|
||||||
g_assert (u < G_N_ELEMENTS(items1));
|
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(items1));
|
g_assert (u == G_N_ELEMENTS(items1));
|
||||||
|
|
||||||
g_free (xpath);
|
g_free (xpath);
|
||||||
mu_msg_iter_destroy (iter);
|
mu_msg_iter_destroy (iter);
|
||||||
}
|
}
|
||||||
@ -226,18 +230,18 @@ int
|
|||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
g_test_init (&argc, &argv, NULL);
|
g_test_init (&argc, &argv, NULL);
|
||||||
|
|
||||||
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,
|
||||||
/* (GLogFunc)black_hole, NULL); */
|
(GLogFunc)black_hole, NULL);
|
||||||
|
|
||||||
rv = g_test_run ();
|
rv = g_test_run ();
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user