* test-mu-store.c: fix test case (gboolean vs MuExitCode)
This commit is contained in:
@ -1,5 +1,7 @@
|
|||||||
|
/* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Copyright (C) 2008-2010 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
|
||||||
** under the terms of the GNU General Public License as published by the
|
** under the terms of the GNU General Public License as published by the
|
||||||
@ -34,147 +36,158 @@
|
|||||||
static void
|
static void
|
||||||
test_mu_store_new_destroy (void)
|
test_mu_store_new_destroy (void)
|
||||||
{
|
{
|
||||||
MuStore *store;
|
MuStore *store;
|
||||||
gchar* tmpdir;
|
gchar* tmpdir;
|
||||||
GError *err;
|
GError *err;
|
||||||
|
|
||||||
tmpdir = test_mu_common_get_random_tmpdir();
|
tmpdir = test_mu_common_get_random_tmpdir();
|
||||||
g_assert (tmpdir);
|
g_assert (tmpdir);
|
||||||
|
|
||||||
err = NULL;
|
err = NULL;
|
||||||
store = mu_store_new (tmpdir, NULL, &err);
|
store = mu_store_new (tmpdir, NULL, &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));
|
||||||
|
|
||||||
mu_store_flush (store);
|
mu_store_flush (store);
|
||||||
mu_store_destroy (store);
|
mu_store_destroy (store);
|
||||||
|
|
||||||
g_free (tmpdir);
|
g_free (tmpdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_mu_store_version (void)
|
test_mu_store_version (void)
|
||||||
{
|
{
|
||||||
MuStore *store;
|
MuStore *store;
|
||||||
gchar* tmpdir;
|
gchar* tmpdir;
|
||||||
GError *err;
|
GError *err;
|
||||||
|
|
||||||
tmpdir = test_mu_common_get_random_tmpdir();
|
tmpdir = test_mu_common_get_random_tmpdir();
|
||||||
g_assert (tmpdir);
|
g_assert (tmpdir);
|
||||||
|
|
||||||
err = NULL;
|
err = NULL;
|
||||||
store = mu_store_new (tmpdir, NULL, &err);
|
store = mu_store_new (tmpdir, NULL, &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_XAPIAN_DB_VERSION,==,
|
||||||
mu_store_version(store));
|
mu_store_version(store));
|
||||||
|
|
||||||
mu_store_destroy (store);
|
mu_store_destroy (store);
|
||||||
g_free (tmpdir);
|
g_free (tmpdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_mu_store_store_msg_and_count (void)
|
test_mu_store_store_msg_and_count (void)
|
||||||
{
|
{
|
||||||
MuMsg *msg;
|
MuMsg *msg;
|
||||||
MuStore *store;
|
MuStore *store;
|
||||||
gchar* tmpdir;
|
gchar* tmpdir;
|
||||||
|
|
||||||
tmpdir = test_mu_common_get_random_tmpdir();
|
tmpdir = test_mu_common_get_random_tmpdir();
|
||||||
g_assert (tmpdir);
|
g_assert (tmpdir);
|
||||||
|
|
||||||
store = mu_store_new (tmpdir, NULL, NULL);
|
store = mu_store_new (tmpdir, NULL, NULL);
|
||||||
g_assert (store);
|
g_assert (store);
|
||||||
|
|
||||||
g_assert_cmpuint (0,==,mu_store_count (store));
|
g_assert_cmpuint (0,==,mu_store_count (store));
|
||||||
|
|
||||||
/* add one */
|
/* add one */
|
||||||
msg = mu_msg_new_from_file (MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,", NULL, NULL);
|
msg = mu_msg_new_from_file (
|
||||||
g_assert (msg);
|
MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,",
|
||||||
g_assert_cmpuint (mu_store_store_msg (store, msg, TRUE), ==, TRUE);
|
NULL, NULL);
|
||||||
g_assert_cmpuint (1,==,mu_store_count (store));
|
g_assert (msg);
|
||||||
g_assert_cmpuint (TRUE,==,mu_store_contains_message
|
g_assert_cmpuint (mu_store_store_msg (store, msg, TRUE), ==, TRUE);
|
||||||
(store, MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,"));
|
g_assert_cmpuint (1,==,mu_store_count (store));
|
||||||
mu_msg_unref (msg);
|
g_assert_cmpuint (TRUE,==,mu_store_contains_message
|
||||||
|
(store,
|
||||||
|
MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,"));
|
||||||
|
mu_msg_unref (msg);
|
||||||
|
|
||||||
/* add another one */
|
/* add another one */
|
||||||
msg = mu_msg_new_from_file (MU_TESTMAILDIR2 "bar/cur/mail3", NULL, NULL);
|
msg = mu_msg_new_from_file (MU_TESTMAILDIR2
|
||||||
g_assert (msg);
|
"bar/cur/mail3", NULL, NULL);
|
||||||
g_assert_cmpuint (mu_store_store_msg (store, msg, TRUE), ==, TRUE);
|
g_assert (msg);
|
||||||
g_assert_cmpuint (2,==,mu_store_count (store));
|
g_assert_cmpuint (mu_store_store_msg (store, msg, TRUE), ==, TRUE);
|
||||||
g_assert_cmpuint (TRUE,==,mu_store_contains_message (store, MU_TESTMAILDIR2 "bar/cur/mail3"));
|
g_assert_cmpuint (2,==,mu_store_count (store));
|
||||||
mu_msg_unref (msg);
|
g_assert_cmpuint (TRUE,==,
|
||||||
|
mu_store_contains_message (store, MU_TESTMAILDIR2
|
||||||
|
"bar/cur/mail3"));
|
||||||
|
mu_msg_unref (msg);
|
||||||
|
|
||||||
/* try to add the first one again. count should be 2 still */
|
/* try to add the first one again. count should be 2 still */
|
||||||
msg = mu_msg_new_from_file (MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,", NULL, NULL);
|
msg = mu_msg_new_from_file
|
||||||
g_assert (msg);
|
(MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,",
|
||||||
g_assert_cmpuint (mu_store_store_msg (store, msg, TRUE), ==, TRUE);
|
NULL, NULL);
|
||||||
g_assert_cmpuint (2,==,mu_store_count (store));
|
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_msg_unref (msg);
|
||||||
|
|
||||||
mu_store_destroy (store);
|
mu_store_destroy (store);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_mu_store_store_msg_remove_and_count (void)
|
test_mu_store_store_msg_remove_and_count (void)
|
||||||
{
|
{
|
||||||
MuMsg *msg;
|
MuMsg *msg;
|
||||||
MuStore *store;
|
MuStore *store;
|
||||||
gchar* tmpdir;
|
gchar* tmpdir;
|
||||||
GError *err;
|
GError *err;
|
||||||
|
|
||||||
tmpdir = test_mu_common_get_random_tmpdir();
|
tmpdir = test_mu_common_get_random_tmpdir();
|
||||||
g_assert (tmpdir);
|
g_assert (tmpdir);
|
||||||
|
|
||||||
store = mu_store_new (tmpdir, NULL, NULL);
|
store = mu_store_new (tmpdir, NULL, NULL);
|
||||||
g_assert (store);
|
g_assert (store);
|
||||||
|
|
||||||
g_assert_cmpuint (0,==,mu_store_count (store));
|
g_assert_cmpuint (0,==,mu_store_count (store));
|
||||||
|
|
||||||
/* add one */
|
/* add one */
|
||||||
err = NULL;
|
err = NULL;
|
||||||
msg = mu_msg_new_from_file (MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,",
|
msg = mu_msg_new_from_file (
|
||||||
NULL, &err);
|
MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,",
|
||||||
g_assert (msg);
|
NULL, &err);
|
||||||
g_assert_cmpuint (mu_store_store_msg (store, msg, TRUE), ==, MU_OK);
|
g_assert (msg);
|
||||||
g_assert_cmpuint (1,==,mu_store_count (store));
|
g_assert_cmpuint (mu_store_store_msg (store, msg, TRUE), ==, TRUE);
|
||||||
mu_msg_unref (msg);
|
g_assert_cmpuint (1,==,mu_store_count (store));
|
||||||
|
mu_msg_unref (msg);
|
||||||
|
|
||||||
/* remove one */
|
/* remove one */
|
||||||
mu_store_remove_path (store, MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,");
|
mu_store_remove_path (store,
|
||||||
g_assert_cmpuint (0,==,mu_store_count (store));
|
MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,");
|
||||||
g_assert_cmpuint (FALSE,==,mu_store_contains_message
|
g_assert_cmpuint (0,==,mu_store_count (store));
|
||||||
(store, MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,"));
|
g_assert_cmpuint (FALSE,==,mu_store_contains_message
|
||||||
|
(store,
|
||||||
|
MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,"));
|
||||||
|
|
||||||
mu_store_destroy (store);
|
mu_store_destroy (store);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
g_test_init (&argc, &argv, NULL);
|
g_test_init (&argc, &argv, NULL);
|
||||||
|
|
||||||
/* mu_runtime_init/uninit */
|
/* mu_runtime_init/uninit */
|
||||||
g_test_add_func ("/mu-store/mu-store-new-destroy",
|
g_test_add_func ("/mu-store/mu-store-new-destroy",
|
||||||
test_mu_store_new_destroy);
|
test_mu_store_new_destroy);
|
||||||
g_test_add_func ("/mu-store/mu-store-version",
|
g_test_add_func ("/mu-store/mu-store-version",
|
||||||
test_mu_store_version);
|
test_mu_store_version);
|
||||||
g_test_add_func ("/mu-store/mu-store-store-and-count",
|
g_test_add_func ("/mu-store/mu-store-store-and-count",
|
||||||
test_mu_store_store_msg_and_count);
|
test_mu_store_store_msg_and_count);
|
||||||
g_test_add_func ("/mu-store/mu-store-store-remove-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_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);
|
||||||
|
|
||||||
return g_test_run ();
|
return g_test_run ();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user