* update test cases for other changes

This commit is contained in:
Dirk-Jan C. Binnema
2011-08-29 23:39:11 +03:00
parent fbc786f2fc
commit ff7a40b3d9
3 changed files with 184 additions and 180 deletions

View File

@ -1,6 +1,6 @@
/* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/
/*
/*
** Copyright (C) 2008-2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** 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
** 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.
**
*/
#if HAVE_CONFIG_H
@ -44,7 +44,7 @@ test_mu_store_new_destroy (void)
g_assert (tmpdir);
err = NULL;
store = mu_store_new (tmpdir, NULL, &err);
store = mu_store_new_writable (tmpdir, NULL, &err);
g_assert (store);
g_assert (err == NULL);
@ -53,7 +53,7 @@ test_mu_store_new_destroy (void)
mu_store_flush (store);
mu_store_destroy (store);
g_free (tmpdir);
g_free (tmpdir);
}
@ -63,27 +63,31 @@ test_mu_store_version (void)
MuStore *store;
gchar* tmpdir;
GError *err;
tmpdir = test_mu_common_get_random_tmpdir();
g_assert (tmpdir);
err = NULL;
store = mu_store_new (tmpdir, NULL, &err);
store = mu_store_new_writable (tmpdir, NULL, &err);
g_assert (store);
mu_store_destroy (store);
store = mu_store_new_read_only (tmpdir, &err);
g_assert (store);
g_assert (err == NULL);
g_assert_cmpuint (0,==,mu_store_count (store));
g_assert_cmpstr (MU_XAPIAN_DB_VERSION,==,
mu_store_version(store));
mu_store_destroy (store);
g_free (tmpdir);
g_free (tmpdir);
}
static void
test_mu_store_store_msg_and_count (void)
{
{
MuMsg *msg;
MuStore *store;
gchar* tmpdir;
@ -91,15 +95,15 @@ test_mu_store_store_msg_and_count (void)
tmpdir = test_mu_common_get_random_tmpdir();
g_assert (tmpdir);
store = mu_store_new (tmpdir, NULL, NULL);
store = mu_store_new_writable (tmpdir, NULL, NULL);
g_assert (store);
g_assert_cmpuint (0,==,mu_store_count (store));
/* add one */
msg = mu_msg_new_from_file (
MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,",
NULL, NULL);
NULL, NULL);
g_assert (msg);
g_assert_cmpuint (mu_store_store_msg (store, msg, TRUE), ==, TRUE);
g_assert_cmpuint (1,==,mu_store_count (store));
@ -116,7 +120,7 @@ test_mu_store_store_msg_and_count (void)
g_assert_cmpuint (2,==,mu_store_count (store));
g_assert_cmpuint (TRUE,==,
mu_store_contains_message (store, MU_TESTMAILDIR2
"bar/cur/mail3"));
"bar/cur/mail3"));
mu_msg_unref (msg);
/* try to add the first one again. count should be 2 still */
@ -126,7 +130,7 @@ test_mu_store_store_msg_and_count (void)
g_assert (msg);
g_assert_cmpuint (mu_store_store_msg (store, msg, TRUE), ==, TRUE);
g_assert_cmpuint (2,==,mu_store_count (store));
mu_msg_unref (msg);
mu_store_destroy (store);
@ -135,20 +139,20 @@ test_mu_store_store_msg_and_count (void)
static void
test_mu_store_store_msg_remove_and_count (void)
{
{
MuMsg *msg;
MuStore *store;
gchar* tmpdir;
GError *err;
tmpdir = test_mu_common_get_random_tmpdir();
g_assert (tmpdir);
store = mu_store_new (tmpdir, NULL, NULL);
store = mu_store_new_writable (tmpdir, NULL, NULL);
g_assert (store);
g_assert_cmpuint (0,==,mu_store_count (store));
/* add one */
err = NULL;
msg = mu_msg_new_from_file (
@ -175,7 +179,7 @@ int
main (int argc, char *argv[])
{
g_test_init (&argc, &argv, NULL);
/* mu_runtime_init/uninit */
g_test_add_func ("/mu-store/mu-store-new-destroy",
test_mu_store_new_destroy);
@ -184,10 +188,10 @@ main (int argc, char *argv[])
g_test_add_func ("/mu-store/mu-store-store-and-count",
test_mu_store_store_msg_and_count);
g_test_add_func ("/mu-store/mu-store-store-remove-and-count",
test_mu_store_store_msg_remove_and_count);
test_mu_store_store_msg_remove_and_count);
g_log_set_handler (NULL,
G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION,
(GLogFunc)black_hole, NULL);
return g_test_run ();
}