2 * test-color.c: Test program for pango_color_parse()
4 * Copyright (C) 2002 Matthias Clasen
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.
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.
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., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
23 #include <pango/pango.h>
25 typedef struct _ColorSpec {
33 static gboolean test_color (ColorSpec *spec)
38 accepted = pango_color_parse (&color, spec->spec);
40 if (accepted == spec->valid &&
42 (color.red == spec->red &&
43 color.green == spec->green &&
44 color.blue == spec->blue)))
51 ColorSpec specs [] = {
52 { "#abc", 1, 0xaaaa, 0xbbbb, 0xcccc },
53 { "#aabbcc", 1, 0xaaaa, 0xbbbb, 0xcccc },
54 { "#aaabbbccc", 1, 0xaaaa, 0xbbbb, 0xcccc },
55 { "#100100100", 1, 0x1001, 0x1001, 0x1001 },
56 { "#aaaabbbbcccc", 1, 0xaaaa, 0xbbbb, 0xcccc },
57 { "#fff", 1, 0xffff, 0xffff, 0xffff },
58 { "#ffffff", 1, 0xffff, 0xffff, 0xffff },
59 { "#fffffffff", 1, 0xffff, 0xffff, 0xffff },
60 { "#ffffffffffff", 1, 0xffff, 0xffff, 0xffff },
61 { "#000", 1, 0x0000, 0x0000, 0x0000 },
62 { "#000000", 1, 0x0000, 0x0000, 0x0000 },
63 { "#000000000", 1, 0x0000, 0x0000, 0x0000 },
64 { "#000000000000", 1, 0x0000, 0x0000, 0x0000 },
65 { "#AAAABBBBCCCC", 1, 0xaaaa, 0xbbbb, 0xcccc },
66 { "#aa bb cc ", 0, 0, 0, 0 },
67 { "#aa bb ccc", 0, 0, 0, 0 },
68 { "#ab", 0, 0, 0, 0 },
69 { "#aabb", 0, 0, 0, 0 },
70 { "#aaabb", 0, 0, 0, 0 },
71 { "aaabb", 0, 0, 0, 0 },
74 { "##fff", 0, 0, 0, 0 },
75 { "#0000ff+", 0, 0, 0, 0 },
76 { "#0000f+", 0, 0, 0, 0 },
77 { "#0x00x10x2", 0, 0, 0, 0 },
82 main (int argc, char *argv[])
87 g_setenv ("PANGO_RC_FILE", "./pangorc", TRUE);
90 for (spec = specs; spec->spec; spec++)
91 success &= test_color (spec);