summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2010-12-01 21:57:36 +0200
committerDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2010-12-01 21:57:36 +0200
commit94487cfe9a799dbd289f9b5c34ced20880f5d4ab (patch)
treeab97e9a3091bff8f2aa3582100b1703213b28fe4 /src
parent3560eecf3a56efa95635cb67fb8a8e2034a80f18 (diff)
* add some simply unit tests for mu-runtime, mu-store
Diffstat (limited to 'src')
-rw-r--r--src/mu-runtime.h2
-rw-r--r--src/mu-store.h16
-rw-r--r--src/tests/Makefile.am8
-rw-r--r--src/tests/test-mu-runtime.c96
4 files changed, 114 insertions, 8 deletions
diff --git a/src/mu-runtime.h b/src/mu-runtime.h
index 0b1a85d..cd1ad07 100644
--- a/src/mu-runtime.h
+++ b/src/mu-runtime.h
@@ -20,7 +20,7 @@
#define __MU_RUNTIME_H__
#include <glib.h>
-#include "mu-config.h"
+#include <mu-config.h>
G_BEGIN_DECLS
diff --git a/src/mu-store.h b/src/mu-store.h
index 4674531..ff982b5 100644
--- a/src/mu-store.h
+++ b/src/mu-store.h
@@ -23,9 +23,9 @@
#include <glib.h>
#include <inttypes.h>
-#include "mu-result.h"
-#include "mu-msg.h"
-#include "mu-error.h"
+#include <mu-result.h>
+#include <mu-msg.h>
+#include <mu-error.h>
G_BEGIN_DECLS
@@ -41,7 +41,9 @@ typedef struct _MuStore MuStore;
*
* @return a new MuStore object, or NULL in case of error
*/
-MuStore* mu_store_new (const char* path, GError **err);
+MuStore* mu_store_new (const char *path, GError **err)
+ G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+
/**
* destroy the MuStore object and free resources
@@ -136,8 +138,8 @@ gboolean mu_store_contains_message (MuStore *store,
* @param stamp a timestamp
*/
void mu_store_set_timestamp (MuStore *store,
- const char* msgpath,
- time_t stamp);
+ const char* msgpath,
+ time_t stamp);
/**
* get the timestamp for a directory
@@ -148,7 +150,7 @@ void mu_store_set_timestamp (MuStore *store,
* @return the timestamp, or 0 in case of error
*/
time_t mu_store_get_timestamp (MuStore *store,
- const char* msgpath);
+ const char* msgpath);
/**
* call a function for each document in the database
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
index 0b6cf55..627123d 100644
--- a/src/tests/Makefile.am
+++ b/src/tests/Makefile.am
@@ -64,6 +64,14 @@ TEST_PROGS += test-mu-msg
test_mu_msg_SOURCES= test-mu-msg.c
test_mu_msg_LDADD= libtestmucommon.la
+TEST_PROGS += test-mu-runtime
+test_mu_runtime_SOURCES= test-mu-runtime.c
+test_mu_runtime_LDADD= libtestmucommon.la
+
+TEST_PROGS += test-mu-store
+test_mu_store_SOURCES= test-mu-store.c dummy.cc
+test_mu_store_LDADD= libtestmucommon.la
+
libtestmucommon_la_SOURCES= \
test-mu-common.c \
diff --git a/src/tests/test-mu-runtime.c b/src/tests/test-mu-runtime.c
new file mode 100644
index 0000000..d46ee4f
--- /dev/null
+++ b/src/tests/test-mu-runtime.c
@@ -0,0 +1,96 @@
+/*
+** Copyright (C) 2008-2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
+**
+** 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
+** Free Software Foundation; either version 3, or (at your option) any
+** later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** 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.
+**
+*/
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif /*HAVE_CONFIG_H*/
+
+#include <glib.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <time.h>
+
+#include <locale.h>
+
+#include "test-mu-common.h"
+#include "src/mu-runtime.h"
+
+static void
+test_mu_runtime_init (void)
+{
+ gchar* tmpdir;
+
+ tmpdir = test_mu_common_get_random_tmpdir();
+ g_assert (tmpdir);
+ g_assert (mu_runtime_init (tmpdir) == TRUE);
+ mu_runtime_uninit ();
+
+ g_assert (mu_runtime_init (tmpdir) == TRUE);
+ mu_runtime_uninit ();
+
+ g_free (tmpdir);
+}
+
+
+static void
+test_mu_runtime_data (void)
+{
+ gchar *homedir, *xdir, *bmfile;
+
+ homedir = test_mu_common_get_random_tmpdir();
+ g_assert (homedir);
+
+ xdir = g_strdup_printf ("%s%c%s", homedir,
+ G_DIR_SEPARATOR, "xapian" );
+
+ bmfile = g_strdup_printf ("%s%c%s", homedir,
+ G_DIR_SEPARATOR, "bookmarks");
+
+ g_assert (mu_runtime_init (homedir) == TRUE);
+
+ g_assert_cmpstr (homedir, ==, mu_runtime_mu_home_dir ());
+ g_assert_cmpstr (xdir, ==, mu_runtime_xapian_dir ());
+ g_assert_cmpstr (bmfile, ==, mu_runtime_bookmarks_file ());
+
+ mu_runtime_uninit ();
+
+ g_free (homedir);
+ g_free (xdir);
+ g_free (bmfile);
+}
+
+
+
+int
+main (int argc, char *argv[])
+{
+ g_test_init (&argc, &argv, NULL);
+
+ /* mu_runtime_init/uninit */
+ g_test_add_func ("/mu-runtime/mu-runtime-init",
+ test_mu_runtime_init);
+ g_test_add_func ("/mu-runtime/mu-runtime-data",
+ test_mu_runtime_data);
+
+ 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 ();
+}