]> Pileus Git - ~andy/gtk/blob - tests/testrc.c
a019ae394dc22812e4fe28fe6c7a229d50c616fc
[~andy/gtk] / tests / testrc.c
1 /* GTK - The GIMP Toolkit
2
3    Copyright (C) 2006 Red Hat, Inc.
4    Author: Matthias Clasen <mclasen@redhat.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 License as
8    published by the Free Software Foundation; either version 2 of the
9    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 the Gnome Library; see the file COPYING.LIB.  If not,
18    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19    Boston, MA 02111-1307, USA.
20 */
21
22 #include <string.h>
23 #include "gtk/gtk.h"
24
25 /* NOTE to compile this test, GTK+ needs to be build without
26  * the _-prefix stripping.
27  */
28 struct {
29   gchar    *pattern;
30   gchar    *test;
31   gboolean  match;
32 } tests[] = {
33   { "", "", TRUE },
34   { "<GtkCheckButton>", "GtkToggleButton", FALSE },
35   { "<GtkCheckButton>", "GtkCheckButton", TRUE },
36   { "<GtkCheckButton>", "GtkRadioButton", TRUE },
37   { "abc*.<GtkButton>.<GtkLabel>.*foo", "abcx.GtkToggleButton.GtkLabel.foo", TRUE },
38   { "*abc.<GtkButton>.foo*", "abc.GtkToggleButton.bar", FALSE },
39   { "*abc.<GtkButton>.foo*", "xabc.GtkToggleButton.fox", FALSE },
40   { NULL, NULL, FALSE }
41 };
42
43 static void
44 load_types (void)
45 {
46   volatile GType type;
47
48   type = gtk_radio_button_get_type ();
49   type = gtk_label_get_type ();
50 }
51
52 int
53 main (int argc, char *argv[])
54 {
55   gint i;
56
57   gtk_init (&argc, &argv);
58   load_types ();
59
60   for (i = 0; tests[i].test; i++)
61     {
62       GSList *list;
63       gchar *path, *rpath;
64       gboolean result;
65       
66       list = _gtk_rc_parse_widget_class_path (tests[i].pattern);
67       path = g_strdup (tests[i].test);
68       rpath = g_utf8_strreverse (path, -1);
69       result = _gtk_rc_match_widget_class (list, strlen (path), path, rpath);
70       g_print ("%d. \"%s\" \"%s\", expected %d, got %d\n",
71                i, tests[i].pattern, tests[i].test, tests[i].match, result);
72       g_assert (result == tests[i].match);
73       g_free (path);
74     }
75
76   return 0;
77 }