[tracker/tracker-0.6] Test tracker-db-action



commit e54b3ad46d06b1fc79953fb548e659cb44c4d3fc
Author: Ivan Frade <ivan frade nokia com>
Date:   Thu Apr 30 13:14:16 2009 +0300

    Test tracker-db-action
    
    Stupid to test an enum but improves the coverage numbers.
---
 tests/libtracker-db/Makefile.am              |   16 ++++++-
 tests/libtracker-db/tracker-db-action-test.c |   67 ++++++++++++++++++++++++++
 2 files changed, 82 insertions(+), 1 deletions(-)

diff --git a/tests/libtracker-db/Makefile.am b/tests/libtracker-db/Makefile.am
index c41059a..2f05a40 100644
--- a/tests/libtracker-db/Makefile.am
+++ b/tests/libtracker-db/Makefile.am
@@ -18,7 +18,8 @@ noinst_PROGRAMS = $(TEST_PROGS)
 
 TEST_PROGS += 								\
 	tracker-index-writer						\
-	tracker-db-file-info
+	tracker-db-file-info						\
+	tracker-db-action
 
 INCLUDES = 								\
 	-DG_LOG_DOMAIN=\"Tracker\"					\
@@ -142,3 +143,16 @@ tracker_db_file_info_LDADD =						\
 	$(GMODULE_LIBS)							\
 	$(GTHREAD_LIBS)							\
 	$(GLIB2_LIBS)							
+
+tracker_db_action_SOURCES =						\
+	tracker-db-action-test.c
+
+tracker_db_action_LDADD = 						\
+	$(top_builddir)/src/libtracker-common/libtracker-common.la 	\
+	$(top_builddir)/src/libtracker-db/libtracker-db.la	 	\
+	$(top_builddir)/tests/common/libtracker-testcommon.la 		\
+	$(QDBM_LIBS)							\
+	$(GCOV_LIBS)							\
+	$(GMODULE_LIBS)							\
+	$(GTHREAD_LIBS)							\
+	$(GLIB2_LIBS)							
diff --git a/tests/libtracker-db/tracker-db-action-test.c b/tests/libtracker-db/tracker-db-action-test.c
new file mode 100644
index 0000000..cf41f8c
--- /dev/null
+++ b/tests/libtracker-db/tracker-db-action-test.c
@@ -0,0 +1,67 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008, Nokia (urho konttori nokia com)
+ *
+ * This library 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 2 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ */
+#include <glib.h>
+#include <libtracker-db/tracker-db-action.h>
+
+static void
+test_actiontype ()
+{
+        TrackerDBAction iter;
+        
+        for (iter = TRACKER_DB_ACTION_IGNORE; 
+             iter != TRACKER_DB_ACTION_FORCE_REFRESH;
+             iter++) {
+                g_assert(tracker_db_action_to_string (iter));
+        }
+}
+
+static void
+test_is_delete ()
+{
+        TrackerDBAction iter;
+        gint            counter = 0;
+
+        /* Only for delete actions in the enum */
+        for (iter = 0; iter < 23; iter++) {
+                if (tracker_db_action_is_delete (iter)) {
+                        counter++;
+                }
+        }
+        g_assert_cmpint (counter, ==, 4);
+}
+
+
+int
+main (int argc, char **argv)
+{
+	int result;
+
+	g_type_init ();
+	g_test_init (&argc, &argv, NULL);
+
+        g_test_add_func ("/libtracker-db/tracker-db-action/to_string",
+                         test_actiontype);
+        g_test_add_func ("/libtracker-db/tracker-db-action/is_delete",
+                         test_is_delete);
+
+	result = g_test_run ();
+
+	return result;
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]