2
* Copyright (C) 1999, 2000 Red Hat Inc.
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Library General Public
6
* License as published by the Free Software Foundation; either
7
* version 2 of the License, or (at your option) any later version.
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Library General Public License for more details.
14
* You should have received a copy of the GNU Library General Public
15
* License along with this library; if not, write to the
16
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
* Boston, MA 02111-1307, USA.
20
#include <gconf/gconf.h>
21
#include <gconf/gconf-changeset.h>
27
check(gboolean condition, const gchar* fmt, ...)
33
description = g_strdup_vprintf(fmt, args);
43
fprintf(stderr, "\n*** FAILED: %s\n", description);
56
"/testing/q/a/b/c/z/w/x/y/z",
68
"dkadfhg;ifb;klndfl;kghpaodigjhrekjt45u62%&@#&@#kl6$%76k@$%&L jk245L:Yj45&@$&KL #$^UY $5",
72
"#$&&^(%^^#$&&*(%^&#!$%$%&^&(%&>>>>>>>>>>>>>!>>>.....<<<<<<<<<<<<<<,,,,,,,&&&&&&",
74
"hello this is a string with spaces and \t\t\t\ttabs",
75
"hello this\nstring\nhas\nnewlines\n \t\t\t\t\t\ttabs and spaces \n",
76
"<?xml version=\"1.0\"?>"
77
"<gmr:Workbook xmlns:gmr=\"http://www.gnome.org/gnumeric/\">"
78
"<gmr:Style HAlign=\"1\" VAlign=\"1\" Fit=\"0\" Orient=\"1\" Shade=\"0\" Format=\"#,##0_);[red](#,##0)\">"
79
"<gmr:Font Unit=\"14\" NAME=\"FontDef1\">-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*</gmr:Font>"
81
"<gmr:Geometry Width=\"610\" Height=\"418\"/>"
84
"<gmr:Name>Sheet 0</gmr:Name>"
85
"<gmr:MaxCol>6</gmr:MaxCol>"
86
"<gmr:MaxRow>14</gmr:MaxRow>"
87
"<gmr:Zoom>1.000000</gmr:Zoom>"
89
"<gmr:ColInfo No=\"0\" Unit=\"97\" MarginA=\"1\" MarginB=\"1\" HardSize=\"0\"/>"
90
"<gmr:ColInfo No=\"1\" Unit=\"80\" MarginA=\"1\" MarginB=\"1\" HardSize=\"0\"/>"
91
"<gmr:ColInfo No=\"2\" Unit=\"80\" MarginA=\"1\" MarginB=\"1\" HardSize=\"0\"/>"
92
"<gmr:ColInfo No=\"3\" Unit=\"80\" MarginA=\"1\" MarginB=\"1\" HardSize=\"0\"/>"
93
"<gmr:ColInfo No=\"6\" Unit=\"80\" MarginA=\"1\" MarginB=\"1\" HardSize=\"0\"/>"
96
"<gmr:RowInfo No=\"0\" Unit=\"20\" MarginA=\"1\" MarginB=\"1\" HardSize=\"0\"/>"
97
"<gmr:RowInfo No=\"1\" Unit=\"20\" MarginA=\"1\" MarginB=\"1\" HardSize=\"0\"/>"
98
"<gmr:RowInfo No=\"2\" Unit=\"20\" MarginA=\"1\" MarginB=\"1\" HardSize=\"0\"/>"
99
"<gmr:RowInfo No=\"3\" Unit=\"20\" MarginA=\"1\" MarginB=\"1\" HardSize=\"0\"/>"
100
"<gmr:RowInfo No=\"4\" Unit=\"20\" MarginA=\"1\" MarginB=\"1\" HardSize=\"0\"/>"
101
"<gmr:RowInfo No=\"5\" Unit=\"20\" MarginA=\"1\" MarginB=\"1\" HardSize=\"0\"/>"
102
"<gmr:RowInfo No=\"6\" Unit=\"20\" MarginA=\"1\" MarginB=\"1\" HardSize=\"0\"/>"
103
"<gmr:RowInfo No=\"7\" Unit=\"20\" MarginA=\"1\" MarginB=\"1\" HardSize=\"0\"/>"
104
"<gmr:RowInfo No=\"8\" Unit=\"20\" MarginA=\"1\" MarginB=\"1\" HardSize=\"0\"/>"
105
"<gmr:RowInfo No=\"9\" Unit=\"20\" MarginA=\"1\" MarginB=\"1\" HardSize=\"0\"/>"
106
"<gmr:RowInfo No=\"10\" Unit=\"20\" MarginA=\"1\" MarginB=\"1\" HardSize=\"0\"/>"
107
"<gmr:RowInfo No=\"11\" Unit=\"20\" MarginA=\"1\" MarginB=\"1\" HardSize=\"0\"/>"
108
"<gmr:RowInfo No=\"12\" Unit=\"20\" MarginA=\"1\" MarginB=\"1\" HardSize=\"0\"/>"
109
"<gmr:RowInfo No=\"13\" Unit=\"20\" MarginA=\"1\" MarginB=\"1\" HardSize=\"0\"/>"
110
"<gmr:RowInfo No=\"14\" Unit=\"20\" MarginA=\"1\" MarginB=\"1\" HardSize=\"0\"/>"
113
"<gmr:Ellipse Pattern=\"0\" Width=\"1\" Color=\"black\">"
114
"<gmr:Points>(258.000000 320.000000)(356.000000 356.000000)</gmr:Points>"
116
"<gmr:Arrow Width=\"1\" Color=\"black\">"
117
"<gmr:Points>(500.000000 131.000000)(332.000000 320.000000)</gmr:Points>"
121
"<gmr:Cell Col=\"3\" Row=\"1\">"
122
"<gmr:Style HAlign=\"1\" VAlign=\"1\" Fit=\"0\" Orient=\"1\" Shade=\"0\" Format=\"#,##0_);[red](#,##0)\">"
123
"<gmr:Font Unit=\"14\" NAME=\"FontDef2\">-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*</gmr:Font>"
125
"<gmr:Content>500</gmr:Content>",
130
static gint ints[] = { -1, -2, -3, 0, 1, 2, 3, 4000, 0xfffff, -0xfffff, G_MININT, G_MAXINT, 0, 0, 57, 83, 95 };
131
static const guint n_ints = sizeof(ints)/sizeof(ints[0]);
133
static gboolean bools[] = { TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE,
134
FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE };
136
static const guint n_bools = sizeof(bools)/sizeof(bools[0]);
138
static gdouble floats[] = { 0.0, 1.0, 2.0, 3.0, 4.0, -10.0, -10.34645764573475637657367346743734878734109870187200000000000009, -100.39458694856908, 3.14159, 4.4532464e7, 9.35e-10, 4.5, 6.7, 8.3, -5.1, G_MINFLOAT, -G_MAXFLOAT, G_MAXFLOAT }; /* don't use max/min double, we don't guarantee that we can store huge numbers */
140
static const guint n_floats = sizeof(floats)/sizeof(floats[0]);
144
check_unset(GConfEngine* conf)
147
const gchar** keyp = NULL;
150
cs = gconf_change_set_new();
156
gconf_change_set_unset(cs, *keyp);
162
gconf_engine_commit_change_set(conf, cs, TRUE, &err);
166
fprintf(stderr, "unset commit failed: %s\n", err->message);
172
gconf_change_set_unref(cs);
180
val = gconf_engine_get (conf, *keyp, &err);
183
valstr = gconf_value_to_string(val);
185
valstr = g_strdup("(none)");
187
check(val == NULL, "unsetting a previously-set value `%s' the value `%s' existed", *keyp, valstr);
196
check_string_storage(GConfEngine* conf)
199
const gchar** keyp = NULL;
200
const gchar** valp = NULL;
203
cs = gconf_change_set_new();
208
while (*keyp && *valp)
210
gconf_change_set_set_string(cs, *keyp, *valp);
216
gconf_engine_commit_change_set(conf, cs, TRUE, &err);
220
fprintf(stderr, "set commit failed: %s\n", err->message);
226
gconf_change_set_unref(cs);
231
while (*keyp && *valp)
235
gotten = gconf_engine_get_string(conf, *keyp, &err);
239
check(gotten == NULL, "string was returned though there was an error");
240
fprintf(stderr, "Failed to get key `%s': %s\n",
241
*keyp, err->message);
248
check (strcmp(gotten, *valp) == 0, "string set/get pair: `%s' set, `%s' got",
262
main (int argc, char** argv)
267
if (!gconf_init(argc, argv, &err))
269
fprintf(stderr, "Failed to init GConf: %s\n", err->message);
275
conf = gconf_engine_get_default();
277
check(conf != NULL, "create the default conf engine");
279
printf("\nChecking string storage via GConfChangeSet:");
281
check_string_storage(conf);
283
gconf_engine_unref(conf);