[tracker/rss-enclosures] Port SPARQL util tests from libtracker-client to libtracker-sparql
- From: Roberto Guido <rguido src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/rss-enclosures] Port SPARQL util tests from libtracker-client to libtracker-sparql
- Date: Wed, 24 Nov 2010 01:27:36 +0000 (UTC)
commit 820d1784279fb77c87acd4699edb909b8559c6c5
Author: Jürg Billeter <j bitron ch>
Date: Tue Aug 24 16:51:33 2010 +0200
Port SPARQL util tests from libtracker-client to libtracker-sparql
configure.ac | 1 +
tests/Makefile.am | 1 +
tests/libtracker-sparql/.gitignore | 1 +
tests/libtracker-sparql/Makefile.am | 29 ++++++++++++++
tests/libtracker-sparql/tracker-test.c | 67 ++++++++++++++++++++++++++++++++
5 files changed, 99 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index abbb3fa..ddabbd1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1937,6 +1937,7 @@ AC_CONFIG_FILES([
tests/libtracker-fts/Makefile
tests/libtracker-fts/limits/Makefile
tests/libtracker-fts/prefix/Makefile
+ tests/libtracker-sparql/Makefile
tests/functional-tests/Makefile
tests/functional-tests/common/Makefile
tests/functional-tests/common/utils/configuration.py
diff --git a/tests/Makefile.am b/tests/Makefile.am
index fa694b6..84b91ce 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -7,6 +7,7 @@ SUBDIRS = \
libtracker-extract \
libtracker-miner \
libtracker-data \
+ libtracker-sparql \
tracker-miner-fs \
tracker-extract \
tracker-steroids \
diff --git a/tests/libtracker-sparql/.gitignore b/tests/libtracker-sparql/.gitignore
new file mode 100644
index 0000000..951d386
--- /dev/null
+++ b/tests/libtracker-sparql/.gitignore
@@ -0,0 +1 @@
+tracker-test
diff --git a/tests/libtracker-sparql/Makefile.am b/tests/libtracker-sparql/Makefile.am
new file mode 100644
index 0000000..972a364
--- /dev/null
+++ b/tests/libtracker-sparql/Makefile.am
@@ -0,0 +1,29 @@
+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)/src/libtracker-sparql \
+ -I$(top_srcdir)/tests/common \
+ $(WARN_CFLAGS) \
+ $(GLIB2_CFLAGS) \
+ $(GCOV_CFLAGS) \
+ $(GMODULE_CFLAGS) \
+ $(GTHREAD_CFLAGS)
+
+tracker_test_SOURCES = \
+ tracker-test.c
+
+tracker_test_LDADD = \
+ $(top_builddir)/src/libtracker-sparql/libtracker-sparql- TRACKER_API_VERSION@.la \
+ $(GMODULE_LIBS) \
+ $(GTHREAD_LIBS) \
+ $(GIO_LIBS) \
+ $(GLIB2_LIBS) \
+ $(GCOV_LIBS)
diff --git a/tests/libtracker-sparql/tracker-test.c b/tests/libtracker-sparql/tracker-test.c
new file mode 100644
index 0000000..1f8d138
--- /dev/null
+++ b/tests/libtracker-sparql/tracker-test.c
@@ -0,0 +1,67 @@
+/*
+ * 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 <tracker-sparql.h>
+
+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_string ()
+{
+ gint i;
+ gchar *result;
+
+ for (i = 0; test_data[i].input != NULL; i++) {
+ result = tracker_sparql_escape_string (test_data[i].input);
+ g_assert_cmpstr (result, ==, test_data[i].output);
+ g_free (result);
+ }
+}
+
+static void
+test_tracker_sparql_escape_uri_vprintf ()
+{
+ gchar *result;
+
+ result = tracker_sparql_escape_uri_printf ("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-sparql/tracker/tracker_sparql_escape_string", test_tracker_sparql_escape_string);
+ g_test_add_func ("/libtracker-sparql/tracker/tracker_sparql_escape_uri_vprintf",
+ test_tracker_sparql_escape_uri_vprintf);
+
+ return g_test_run ();
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]