[tracker/crawling-interval] Tests: initial test to libtracker-client



commit c59eb6153db71325fe22daa45b1b62521edb00a3
Author: Ivan Frade <ivan frade nokia com>
Date:   Wed Apr 28 13:44:44 2010 +0300

    Tests: initial test to libtracker-client

 configure.ac                           |    1 +
 tests/Makefile.am                      |    1 +
 tests/libtracker-client/Makefile.am    |   30 ++++++++++++
 tests/libtracker-client/tracker-test.c |   80 ++++++++++++++++++++++++++++++++
 4 files changed, 112 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index fd87b9d..84319f5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1682,6 +1682,7 @@ AC_CONFIG_FILES([
 	src/plugins/nautilus/Makefile
 	src/vapi/Makefile
 	tests/common/Makefile
+        tests/libtracker-client/Makefile
 	tests/libtracker-common/Makefile
 	tests/libtracker-extract/Makefile
 	tests/libtracker-data/Makefile
diff --git a/tests/Makefile.am b/tests/Makefile.am
index cbdf251..3b90efb 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -3,6 +3,7 @@ include $(top_srcdir)/Makefile.decl
 SUBDIRS = 			\
 	common 			\
 	libtracker-common	\
+	libtracker-client	\
 	libtracker-extract	\
 	libtracker-miner	\
 	libtracker-data		\
diff --git a/tests/libtracker-client/Makefile.am b/tests/libtracker-client/Makefile.am
new file mode 100644
index 0000000..d437a69
--- /dev/null
+++ b/tests/libtracker-client/Makefile.am
@@ -0,0 +1,30 @@
+include $(top_srcdir)/Makefile.decl
+
+noinst_PROGRAMS = $(TEST_PROGS)
+
+TEST_PROGS += 								\
+	tracker-test
+
+INCLUDES = 								\
+	-DG_LOG_DOMAIN=\"Tracker\"					\
+	-DTRACKER_COMPILATION						\
+	-I$(top_srcdir)/src						\
+	-I$(top_srcdir)/tests/common					\
+	$(WARN_CFLAGS)							\
+	$(GLIB2_CFLAGS)							\
+	$(GCOV_CFLAGS)							\
+	$(GMODULE_CFLAGS)						\
+	$(GTHREAD_CFLAGS)						\
+	$(DBUS_CFLAGS)
+
+tracker_test_SOURCES = 							\
+	tracker-test.c
+
+tracker_test_LDADD = 							\
+	$(top_builddir)/src/libtracker-client/libtracker-client- TRACKER_API_VERSION@.la \
+	$(DBUS_LIBS)							\
+	$(GMODULE_LIBS)							\
+	$(GTHREAD_LIBS)							\
+	$(GIO_LIBS)							\
+	$(GLIB2_LIBS)							\
+	$(GCOV_LIBS)
\ No newline at end of file
diff --git a/tests/libtracker-client/tracker-test.c b/tests/libtracker-client/tracker-test.c
new file mode 100644
index 0000000..da6cef1
--- /dev/null
+++ b/tests/libtracker-client/tracker-test.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2008, Nokia <ivan frade 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-client/tracker.h>
+
+static void
+test_tracker_client ()
+{
+        TrackerClient *client;
+
+        client = tracker_client_new (0, -1);
+        g_assert (client);
+
+        g_object_unref (client);
+}
+
+typedef struct {
+        const gchar *input ;
+        const gchar *output;
+} ESCAPE_TEST_DATA;
+
+ESCAPE_TEST_DATA  test_data []  = {
+        {"SELECT \"a\"", "SELECT \\\"a\\\""},
+        {"SELECT ?u \t \n \r \b \f", "SELECT ?u \\t \\n \\r \\b \\f"},
+        {NULL, NULL }
+};
+
+static void
+test_tracker_sparql_escape ()
+{
+        gint i;
+        gchar *result;
+
+        for (i = 0; test_data[i].input != NULL; i++) {
+                result = tracker_sparql_escape (test_data[i].input);
+                g_assert_cmpstr (result, ==, test_data[i].output);
+                g_free (result);
+        }
+}
+
+static void
+test_tracker_uri_vprintf_escaped ()
+{
+        gchar *result;
+
+        result = tracker_uri_printf_escaped ("test:uri:contact-%d", 14, NULL);
+        g_assert_cmpstr (result, ==, "test:uri:contact-14");
+        g_free (result);
+        
+}
+
+gint 
+main (gint argc, gchar **argv)
+{
+        g_type_init ();
+        g_test_init (&argc, &argv, NULL);
+
+        g_test_add_func ("/libtracker-client/tracker/tracker_client", test_tracker_client);
+        g_test_add_func ("/libtracker-client/tracker/tracker_sparql_escape", test_tracker_sparql_escape);
+        g_test_add_func ("/libtracker-client/tracker/tracker_uri_vprintf_escaped", 
+                         test_tracker_uri_vprintf_escaped);
+
+        return g_test_run ();
+}



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