7916912bb0c0852a8ed89f4677e9e7225c971363
[profile/ivi/GUPnP-AV.git] / tests / check-search.c
1 /*
2  * Copyright (C) 2008 OpenedHand Ltd.
3  *
4  * Authors: Jorn Baayen <jorn@openedhand.com>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21
22 #include <libgupnp-av/gupnp-search-criteria-parser.h>
23 #include <stdlib.h>
24
25 static const char * const searches[] = {
26         "dc:title contains \"foo\"",
27         "dc:title contains 'foo'",
28         "upnp:class = \"object.container.person.musicArtist\"",
29         "upnp:class = \"object.container.person.musicArtist\" and @refID exists false",
30 };
31
32 int
33 main (int argc, char **argv)
34 {
35         GUPnPSearchCriteriaParser *parser;
36         GError *error;
37         int i;
38
39 #if !GLIB_CHECK_VERSION (2, 35, 0)
40         g_type_init ();
41 #endif
42
43         parser = gupnp_search_criteria_parser_new ();
44
45         for (i = 0; i < G_N_ELEMENTS (searches); i++) {
46                 error = NULL;
47                 gupnp_search_criteria_parser_parse_text (parser, searches[i], &error);
48                 if (error) {
49                         g_printerr ("\n\nCannot parse '%s': %s\n",
50                                     searches[i], error->message);
51                         g_error_free (error);
52
53                         return EXIT_FAILURE;
54                 }
55                 /* TODO: obviously an important next step is to verify that the
56                    data was actually parsed correctly */
57                 g_print (".");
58         }
59
60         g_print ("\n");
61         return EXIT_SUCCESS;
62 }