summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoss Burton <ross@openedhand.com>2008-01-17 21:18:57 +0000
committerRoss Burton <ross@openedhand.com>2008-01-17 21:18:57 +0000
commit9745865295ea6b321333efcc348c3237183c25f8 (patch)
tree9e834aa1c02b4a535cf11e4bc854afd153e61dbb /tests
parent6babf4a21e90e66da9242327bc1cd2e625469aa9 (diff)
downloadgupnp-av-9745865295ea6b321333efcc348c3237183c25f8.tar.gz
2008-01-17 Ross Burton <ross@openedhand.com>
* tests/Makefile.am: * tests/check-search.c: Add very basic test suite for the search expression parser. git-svn-id: https://svn.o-hand.com/repos/gupnp/trunk/gupnp-av@693 d8cb91d7-bff9-0310-92b9-80b65e4482b2
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am8
-rw-r--r--tests/check-search.c57
2 files changed, 63 insertions, 2 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6254772..cab44c5 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,6 +1,10 @@
AM_CFLAGS = $(LIBGUPNP_CFLAGS) -I$(top_srcdir)
+AM_LDFLAGS = $(top_builddir)/libgupnp-av/libgupnp-av-1.0.la
noinst_PROGRAMS = test-search-criteria-parser
-
test_search_criteria_parser_SOURCES = test-search-criteria-parser.c
-test_search_criteria_parser_LDADD = $(top_builddir)/libgupnp-av/libgupnp-av-1.0.la
+
+check_PROGRAMS = check-search
+check_search_SOURCES = check-search.c
+
+TESTS = $(check_PROGRAMS)
diff --git a/tests/check-search.c b/tests/check-search.c
new file mode 100644
index 0000000..30d9968
--- /dev/null
+++ b/tests/check-search.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2008 OpenedHand Ltd.
+ *
+ * Authors: Jorn Baayen <jorn@openedhand.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <libgupnp-av/gupnp-search-criteria-parser.h>
+
+static const char * const searches[] = {
+ "dc:title contains \"foo\"",
+ "dc:title contains 'foo'",
+ "upnp:class = \"object.container.person.musicArtist\"",
+ "upnp:class = \"object.container.person.musicArtist\" and @refID exists false",
+};
+
+int
+main (int argc, char **argv)
+{
+ GUPnPSearchCriteriaParser *parser;
+ GError *error;
+ int i;
+
+ g_type_init ();
+
+ parser = gupnp_search_criteria_parser_new ();
+
+ for (i = 0; i < G_N_ELEMENTS (searches); i++) {
+ error = NULL;
+ gupnp_search_criteria_parser_parse_text (parser, searches[i], &error);
+ if (error) {
+ g_print ("\n\nCannot parse '%s'", searches[i]);
+ g_error (error->message);
+ return 1;
+ }
+ /* TODO: obviously an important next step is to verify that the
+ data was actually parsed correctly */
+ g_print (".");
+ }
+
+ g_print ("\n");
+ return 0;
+}