|
1 /* GLIB - Library of useful routines for C programming |
|
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald |
|
3 * Portion Copyright © 2008-09 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. |
|
4 * This library is free software; you can redistribute it and/or |
|
5 * modify it under the terms of the GNU Lesser 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. |
|
8 * |
|
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 * Lesser General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU Lesser 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. |
|
18 */ |
|
19 |
|
20 /* |
|
21 * Modified by the GLib Team and others 1997-2000. See the AUTHORS |
|
22 * file for a list of people on the GLib Team. See the ChangeLog |
|
23 * files for a list of changes. These files are distributed with |
|
24 * GLib at ftp://ftp.gtk.org/pub/gtk/. |
|
25 */ |
|
26 |
|
27 #include "config.h" |
|
28 |
|
29 #undef G_DISABLE_ASSERT |
|
30 #undef G_LOG_DOMAIN |
|
31 |
|
32 #ifdef GLIB_COMPILATION |
|
33 #undef GLIB_COMPILATION |
|
34 #endif |
|
35 |
|
36 #include <stdio.h> |
|
37 #include <string.h> |
|
38 #include <errno.h> |
|
39 |
|
40 #include "glib.h" |
|
41 #include <glib/gstdio.h> |
|
42 |
|
43 |
|
44 #ifdef __SYMBIAN32__ |
|
45 #include <sys/stat.h> |
|
46 #include <glib_global.h> |
|
47 #include "mrt2_glib2_test.h" |
|
48 #endif /*__SYMBIAN32__*/ |
|
49 |
|
50 |
|
51 #ifdef HAVE_UNISTD_H |
|
52 #include <sys/unistd.h> |
|
53 #endif |
|
54 |
|
55 #ifdef G_OS_WIN32 |
|
56 #include <io.h> /* For read(), write() etc */ |
|
57 #endif |
|
58 |
|
59 |
|
60 |
|
61 static int array[10000]; |
|
62 static gboolean failed = FALSE; |
|
63 |
|
64 /* We write (m ? m : "") even in the m != NULL case to suppress a warning with GCC-3.1 |
|
65 */ |
|
66 #define TEST(m,cond) G_STMT_START { failed = !(cond); \ |
|
67 if (failed) \ |
|
68 { assert_failed = TRUE; \ |
|
69 if (!m) \ |
|
70 g_print ("\n(%s:%d) failed for: %s\n", __FILE__, __LINE__, ( # cond )); \ |
|
71 else \ |
|
72 g_print ("\n(%s:%d) failed for: %s: (%s)\n", __FILE__, __LINE__, ( # cond ), (gchar*)(m ? m : "")); \ |
|
73 } \ |
|
74 } G_STMT_END |
|
75 |
|
76 #define C2P(c) ((gpointer) ((long) (c))) |
|
77 #define P2C(p) ((gchar) ((long) (p))) |
|
78 |
|
79 #define GLIB_TEST_STRING "el dorado " |
|
80 #define GLIB_TEST_STRING_5 "el do" |
|
81 |
|
82 static gboolean |
|
83 node_build_string (GNode *node, |
|
84 gpointer data) |
|
85 { |
|
86 gchar **p = data; |
|
87 gchar *string; |
|
88 gchar c[2] = "_"; |
|
89 |
|
90 c[0] = P2C (node->data); |
|
91 |
|
92 string = g_strconcat (*p ? *p : "", c, NULL); |
|
93 g_free (*p); |
|
94 *p = string; |
|
95 |
|
96 return FALSE; |
|
97 } |
|
98 |
|
99 static void |
|
100 g_node_test (void) |
|
101 { |
|
102 GNode *root; |
|
103 GNode *node; |
|
104 GNode *node_B; |
|
105 GNode *node_F; |
|
106 GNode *node_G; |
|
107 GNode *node_J; |
|
108 guint i; |
|
109 gchar *tstring, *cstring; |
|
110 |
|
111 //g_print ("checking n-way trees: "); |
|
112 failed = FALSE; |
|
113 |
|
114 root = g_node_new (C2P ('A')); |
|
115 TEST (NULL, g_node_depth (root) == 1 && g_node_max_height (root) == 1); |
|
116 |
|
117 node_B = g_node_new (C2P ('B')); |
|
118 g_node_append (root, node_B); |
|
119 TEST (NULL, root->children == node_B); |
|
120 |
|
121 g_node_append_data (node_B, C2P ('E')); |
|
122 g_node_prepend_data (node_B, C2P ('C')); |
|
123 g_node_insert (node_B, 1, g_node_new (C2P ('D'))); |
|
124 |
|
125 node_F = g_node_new (C2P ('F')); |
|
126 g_node_append (root, node_F); |
|
127 TEST (NULL, root->children->next == node_F); |
|
128 |
|
129 node_G = g_node_new (C2P ('G')); |
|
130 g_node_append (node_F, node_G); |
|
131 node_J = g_node_new (C2P ('J')); |
|
132 g_node_prepend (node_G, node_J); |
|
133 g_node_insert (node_G, 42, g_node_new (C2P ('K'))); |
|
134 g_node_insert_data (node_G, 0, C2P ('H')); |
|
135 g_node_insert (node_G, 1, g_node_new (C2P ('I'))); |
|
136 |
|
137 TEST (NULL, g_node_depth (root) == 1); |
|
138 TEST (NULL, g_node_max_height (root) == 4); |
|
139 TEST (NULL, g_node_depth (node_G->children->next) == 4); |
|
140 TEST (NULL, g_node_n_nodes (root, G_TRAVERSE_LEAFS) == 7); |
|
141 TEST (NULL, g_node_n_nodes (root, G_TRAVERSE_NON_LEAFS) == 4); |
|
142 TEST (NULL, g_node_n_nodes (root, G_TRAVERSE_ALL) == 11); |
|
143 TEST (NULL, g_node_max_height (node_F) == 3); |
|
144 TEST (NULL, g_node_n_children (node_G) == 4); |
|
145 TEST (NULL, g_node_find_child (root, G_TRAVERSE_ALL, C2P ('F')) == node_F); |
|
146 TEST (NULL, g_node_find (root, G_LEVEL_ORDER, G_TRAVERSE_NON_LEAFS, C2P ('I')) == NULL); |
|
147 TEST (NULL, g_node_find (root, G_IN_ORDER, G_TRAVERSE_LEAFS, C2P ('J')) == node_J); |
|
148 |
|
149 for (i = 0; i < g_node_n_children (node_B); i++) |
|
150 { |
|
151 node = g_node_nth_child (node_B, i); |
|
152 TEST (NULL, P2C (node->data) == ('C' + i)); |
|
153 } |
|
154 |
|
155 for (i = 0; i < g_node_n_children (node_G); i++) |
|
156 TEST (NULL, g_node_child_position (node_G, g_node_nth_child (node_G, i)) == i); |
|
157 |
|
158 /* we have built: A |
|
159 * / \ |
|
160 * B F |
|
161 * / | \ \ |
|
162 * C D E G |
|
163 * / /\ \ |
|
164 * H I J K |
|
165 * |
|
166 * for in-order traversal, 'G' is considered to be the "left" |
|
167 * child of 'F', which will cause 'F' to be the last node visited. |
|
168 */ |
|
169 |
|
170 tstring = NULL; |
|
171 g_node_traverse (root, G_PRE_ORDER, G_TRAVERSE_ALL, -1, node_build_string, &tstring); |
|
172 TEST (tstring, strcmp (tstring, "ABCDEFGHIJK") == 0); |
|
173 g_free (tstring); tstring = NULL; |
|
174 g_node_traverse (root, G_POST_ORDER, G_TRAVERSE_ALL, -1, node_build_string, &tstring); |
|
175 TEST (tstring, strcmp (tstring, "CDEBHIJKGFA") == 0); |
|
176 g_free (tstring); tstring = NULL; |
|
177 g_node_traverse (root, G_IN_ORDER, G_TRAVERSE_ALL, -1, node_build_string, &tstring); |
|
178 TEST (tstring, strcmp (tstring, "CBDEAHGIJKF") == 0); |
|
179 g_free (tstring); tstring = NULL; |
|
180 g_node_traverse (root, G_LEVEL_ORDER, G_TRAVERSE_ALL, -1, node_build_string, &tstring); |
|
181 TEST (tstring, strcmp (tstring, "ABFCDEGHIJK") == 0); |
|
182 g_free (tstring); tstring = NULL; |
|
183 |
|
184 g_node_traverse (root, G_LEVEL_ORDER, G_TRAVERSE_LEAFS, -1, node_build_string, &tstring); |
|
185 TEST (tstring, strcmp (tstring, "CDEHIJK") == 0); |
|
186 g_free (tstring); tstring = NULL; |
|
187 g_node_traverse (root, G_PRE_ORDER, G_TRAVERSE_NON_LEAFS, -1, node_build_string, &tstring); |
|
188 TEST (tstring, strcmp (tstring, "ABFG") == 0); |
|
189 g_free (tstring); tstring = NULL; |
|
190 |
|
191 g_node_reverse_children (node_B); |
|
192 g_node_reverse_children (node_G); |
|
193 |
|
194 g_node_traverse (root, G_LEVEL_ORDER, G_TRAVERSE_ALL, -1, node_build_string, &tstring); |
|
195 TEST (tstring, strcmp (tstring, "ABFEDCGKJIH") == 0); |
|
196 g_free (tstring); tstring = NULL; |
|
197 |
|
198 cstring = NULL; |
|
199 node = g_node_copy (root); |
|
200 TEST (NULL, g_node_n_nodes (root, G_TRAVERSE_ALL) == g_node_n_nodes (node, G_TRAVERSE_ALL)); |
|
201 TEST (NULL, g_node_max_height (root) == g_node_max_height (node)); |
|
202 g_node_traverse (root, G_IN_ORDER, G_TRAVERSE_ALL, -1, node_build_string, &tstring); |
|
203 g_node_traverse (node, G_IN_ORDER, G_TRAVERSE_ALL, -1, node_build_string, &cstring); |
|
204 TEST (cstring, strcmp (tstring, cstring) == 0); |
|
205 g_free (tstring); tstring = NULL; |
|
206 g_free (cstring); cstring = NULL; |
|
207 g_node_destroy (node); |
|
208 |
|
209 g_node_destroy (root); |
|
210 |
|
211 /* allocation tests */ |
|
212 |
|
213 root = g_node_new (NULL); |
|
214 node = root; |
|
215 |
|
216 for (i = 0; i < 2048; i++) |
|
217 { |
|
218 g_node_append (node, g_node_new (NULL)); |
|
219 if ((i%5) == 4) |
|
220 node = node->children->next; |
|
221 } |
|
222 TEST (NULL, g_node_max_height (root) > 100); |
|
223 TEST (NULL, g_node_n_nodes (root, G_TRAVERSE_ALL) == 1 + 2048); |
|
224 |
|
225 g_node_destroy (root); |
|
226 |
|
227 if (failed) |
|
228 g_print ("g_node_test failed\n"); |
|
229 } |
|
230 |
|
231 static gboolean |
|
232 my_hash_callback_remove (gpointer key, |
|
233 gpointer value, |
|
234 gpointer user_data) |
|
235 { |
|
236 int *d = value; |
|
237 |
|
238 if ((*d) % 2) |
|
239 return TRUE; |
|
240 |
|
241 return FALSE; |
|
242 } |
|
243 |
|
244 static void |
|
245 my_hash_callback_remove_test (gpointer key, |
|
246 gpointer value, |
|
247 gpointer user_data) |
|
248 { |
|
249 int *d = value; |
|
250 |
|
251 if ((*d) % 2) |
|
252 g_print ("bad!\n"); |
|
253 } |
|
254 |
|
255 static void |
|
256 my_hash_callback (gpointer key, |
|
257 gpointer value, |
|
258 gpointer user_data) |
|
259 { |
|
260 int *d = value; |
|
261 *d = 1; |
|
262 } |
|
263 |
|
264 static guint |
|
265 my_hash (gconstpointer key) |
|
266 { |
|
267 return (guint) *((const gint*) key); |
|
268 } |
|
269 |
|
270 static gboolean |
|
271 my_hash_equal (gconstpointer a, |
|
272 gconstpointer b) |
|
273 { |
|
274 return *((const gint*) a) == *((const gint*) b); |
|
275 } |
|
276 |
|
277 static gint |
|
278 my_list_compare_one (gconstpointer a, gconstpointer b) |
|
279 { |
|
280 gint one = *((const gint*)a); |
|
281 gint two = *((const gint*)b); |
|
282 return one-two; |
|
283 } |
|
284 |
|
285 static gint |
|
286 my_list_compare_two (gconstpointer a, gconstpointer b) |
|
287 { |
|
288 gint one = *((const gint*)a); |
|
289 gint two = *((const gint*)b); |
|
290 return two-one; |
|
291 } |
|
292 |
|
293 /* static void |
|
294 my_list_print (gpointer a, gpointer b) |
|
295 { |
|
296 gint three = *((gint*)a); |
|
297 g_print("%d", three); |
|
298 }; */ |
|
299 |
|
300 static gint |
|
301 my_compare (gconstpointer a, |
|
302 gconstpointer b) |
|
303 { |
|
304 const char *cha = a; |
|
305 const char *chb = b; |
|
306 |
|
307 return *cha - *chb; |
|
308 } |
|
309 |
|
310 static gint |
|
311 my_traverse (gpointer key, |
|
312 gpointer value, |
|
313 gpointer data) |
|
314 { |
|
315 char *ch = key; |
|
316 g_print ("%c ", *ch); |
|
317 return FALSE; |
|
318 } |
|
319 |
|
320 static gboolean |
|
321 find_first_that(gpointer key, |
|
322 gpointer value, |
|
323 gpointer user_data) |
|
324 { |
|
325 gint *v = value; |
|
326 gint *test = user_data; |
|
327 return (*v == *test); |
|
328 } |
|
329 |
|
330 |
|
331 static gboolean |
|
332 test_g_mkdir_with_parents_1 (const gchar *base) |
|
333 { |
|
334 char *p0 = g_build_filename (base, "fum", NULL); |
|
335 char *p1 = g_build_filename (p0, "tem", NULL); |
|
336 char *p2 = g_build_filename (p1, "zap", NULL); |
|
337 FILE *f; |
|
338 |
|
339 g_remove (p2); |
|
340 g_remove (p1); |
|
341 g_remove (p0); |
|
342 |
|
343 if (g_file_test (p0, G_FILE_TEST_EXISTS)) |
|
344 { |
|
345 g_print ("failed, %s exists, cannot test g_mkdir_with_parents\n", p0); |
|
346 return FALSE; |
|
347 } |
|
348 |
|
349 if (g_file_test (p1, G_FILE_TEST_EXISTS)) |
|
350 { |
|
351 g_print ("failed, %s exists, cannot test g_mkdir_with_parents\n", p1); |
|
352 g_assert(FALSE && "testglib"); |
|
353 return FALSE; |
|
354 } |
|
355 |
|
356 if (g_file_test (p2, G_FILE_TEST_EXISTS)) |
|
357 { |
|
358 g_print ("failed, %s exists, cannot test g_mkdir_with_parents\n", p2); |
|
359 g_assert(FALSE && "testglib"); |
|
360 return FALSE; |
|
361 } |
|
362 |
|
363 #ifdef __SYMBIAN32__ |
|
364 if (g_mkdir_with_parents (p2, S_IWUSR) == -1) |
|
365 { |
|
366 g_print ("failed, g_mkdir_with_parents(%s) failed: %s\n", p2, g_strerror (errno)); |
|
367 g_assert(FALSE && "testglib"); |
|
368 return FALSE; |
|
369 } |
|
370 #else |
|
371 if (g_mkdir_with_parents (p2, 0666) == -1) |
|
372 { |
|
373 g_print ("failed, g_mkdir_with_parents(%s) failed: %s\n", p2, g_strerror (errno)); |
|
374 g_assert(FALSE && "testglib"); |
|
375 return FALSE; |
|
376 } |
|
377 #endif |
|
378 |
|
379 if (!g_file_test (p2, G_FILE_TEST_IS_DIR)) |
|
380 { |
|
381 g_print ("failed, g_mkdir_with_parents(%s) succeeded, but %s is not a directory\n", p2, p2); |
|
382 g_assert(FALSE && "testglib"); |
|
383 return FALSE; |
|
384 } |
|
385 |
|
386 if (!g_file_test (p1, G_FILE_TEST_IS_DIR)) |
|
387 { |
|
388 g_print ("failed, g_mkdir_with_parents(%s) succeeded, but %s is not a directory\n", p2, p1); |
|
389 g_assert(FALSE && "testglib"); |
|
390 return FALSE; |
|
391 } |
|
392 |
|
393 if (!g_file_test (p0, G_FILE_TEST_IS_DIR)) |
|
394 { |
|
395 g_print ("failed, g_mkdir_with_parents(%s) succeeded, but %s is not a directory\n", p2, p0); |
|
396 g_assert(FALSE && "testglib"); |
|
397 return FALSE; |
|
398 } |
|
399 |
|
400 g_rmdir (p2); |
|
401 if (g_file_test (p2, G_FILE_TEST_EXISTS)) |
|
402 { |
|
403 g_print ("failed, did g_rmdir(%s), but %s is still there\n", p2, p2); |
|
404 g_assert(FALSE && "testglib"); |
|
405 return FALSE; |
|
406 } |
|
407 |
|
408 g_rmdir (p1); |
|
409 if (g_file_test (p1, G_FILE_TEST_EXISTS)) |
|
410 { |
|
411 g_print ("failed, did g_rmdir(%s), but %s is still there\n", p1, p1); |
|
412 g_assert(FALSE && "testglib"); |
|
413 return FALSE; |
|
414 } |
|
415 |
|
416 f = g_fopen (p1, "w"); |
|
417 if (f == NULL) |
|
418 { |
|
419 g_print ("failed, couldn't create file %s\n", p1); |
|
420 g_assert(FALSE && "testglib"); |
|
421 return FALSE; |
|
422 } |
|
423 fclose (f); |
|
424 |
|
425 #ifdef __SYMBIAN32__ |
|
426 if (g_mkdir_with_parents (p1,S_IWUSR) == 0) |
|
427 { |
|
428 g_print ("failed, g_mkdir_with_parents(%s) succeeded, even if %s is a file\n", p1, p1); |
|
429 g_assert(FALSE && "testglib"); |
|
430 return FALSE; |
|
431 } |
|
432 #else |
|
433 if (g_mkdir_with_parents (p1, 0666) == 0) |
|
434 { |
|
435 g_print ("failed, g_mkdir_with_parents(%s) succeeded, even if %s is a file\n", p1, p1); |
|
436 g_assert(FALSE && "testglib"); |
|
437 return FALSE; |
|
438 } |
|
439 #endif |
|
440 |
|
441 #ifdef __SYMBIAN32__ |
|
442 if (g_mkdir_with_parents (p2, S_IWUSR) == 0) |
|
443 { |
|
444 g_print ("failed, g_mkdir_with_parents(%s) succeeded, even if %s is a file\n", p2, p1); |
|
445 g_assert(FALSE && "testglib"); |
|
446 return FALSE; |
|
447 } |
|
448 #else |
|
449 if (g_mkdir_with_parents (p2, 0666) == 0) |
|
450 { |
|
451 g_print ("failed, g_mkdir_with_parents(%s) succeeded, even if %s is a file\n", p2, p1); |
|
452 g_assert(FALSE && "testglib"); |
|
453 return FALSE; |
|
454 } |
|
455 #endif |
|
456 |
|
457 g_remove (p2); |
|
458 g_remove (p1); |
|
459 g_remove (p0); |
|
460 |
|
461 return TRUE; |
|
462 } |
|
463 |
|
464 static gboolean |
|
465 test_g_mkdir_with_parents (void) |
|
466 { |
|
467 #ifdef __SYMBIAN32__ |
|
468 if (!test_g_mkdir_with_parents_1 ("c:\\hum")) |
|
469 return FALSE; |
|
470 g_remove ("c:\\hum"); |
|
471 #else |
|
472 if (!test_g_mkdir_with_parents_1 ("hum")) |
|
473 return FALSE; |
|
474 g_remove ("hum"); |
|
475 #endif |
|
476 |
|
477 #ifndef __SYMBIAN32__ |
|
478 if (!test_g_mkdir_with_parents_1 ("hii///haa/hee")) |
|
479 return FALSE; |
|
480 g_remove ("hii/haa/hee"); |
|
481 g_remove ("hii/haa"); |
|
482 g_remove ("hii"); |
|
483 |
|
484 #endif |
|
485 |
|
486 if (!test_g_mkdir_with_parents_1 (g_get_current_dir ())) |
|
487 return FALSE; |
|
488 |
|
489 return TRUE; |
|
490 } |
|
491 |
|
492 static void |
|
493 test_g_parse_debug_string (void) |
|
494 { |
|
495 GDebugKey keys[3] = { |
|
496 { "foo", 1 }, |
|
497 { "bar", 2 }, |
|
498 { "baz", 4 } |
|
499 }; |
|
500 guint n_keys = 3; |
|
501 guint result; |
|
502 |
|
503 result = g_parse_debug_string ("bar:foo:blubb", keys, n_keys); |
|
504 g_assert (result == 3); |
|
505 |
|
506 result = g_parse_debug_string (":baz::_E@~!_::", keys, n_keys); |
|
507 g_assert (result == 4); |
|
508 |
|
509 result = g_parse_debug_string ("", keys, n_keys); |
|
510 g_assert (result == 0); |
|
511 |
|
512 result = g_parse_debug_string (" : ", keys, n_keys); |
|
513 g_assert (result == 0); |
|
514 } |
|
515 |
|
516 |
|
517 int |
|
518 main (int argc, |
|
519 char *argv[]) |
|
520 { |
|
521 const gchar *s; |
|
522 gchar **sv; |
|
523 GList *list, *t; |
|
524 GSList *slist, *st; |
|
525 GHashTable *hash_table; |
|
526 GMemChunk *mem_chunk; |
|
527 GStringChunk *string_chunk; |
|
528 GTimer *timer, *timer2; |
|
529 gdouble elapsed; |
|
530 gulong elapsed_usecs; |
|
531 gint nums[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; |
|
532 gint morenums[10] = { 8, 9, 7, 0, 3, 2, 5, 1, 4, 6}; |
|
533 gchar *string; |
|
534 gint value = 120; |
|
535 gint *pvalue=NULL; |
|
536 |
|
537 gchar *mem[10000], *tmp_string = NULL, *tmp_string_2; |
|
538 gint i, j; |
|
539 GArray *garray; |
|
540 GPtrArray *gparray; |
|
541 GByteArray *gbarray; |
|
542 GString *string1, *string2; |
|
543 const gchar *charset; |
|
544 GTree *tree; |
|
545 char chars[62]; |
|
546 GRelation *relation; |
|
547 GTuples *tuples; |
|
548 gint data [1024]; |
|
549 struct { |
|
550 gchar *filename; |
|
551 gchar *dirname; |
|
552 } dirname_checks[] = { |
|
553 { "/", "/" }, |
|
554 { "////", "/" }, |
|
555 { ".////", "." }, |
|
556 { "../", ".." }, |
|
557 { "..////", ".." }, |
|
558 { "a/b", "a" }, |
|
559 { "a/b/", "a/b" }, |
|
560 { "c///", "c" }, |
|
561 #ifdef G_OS_WIN32 |
|
562 { "\\", "\\" }, |
|
563 { ".\\\\\\\\", "." }, |
|
564 { "..\\", ".." }, |
|
565 { "..\\\\\\\\", ".." }, |
|
566 { "a\\b", "a" }, |
|
567 { "a\\b/", "a\\b" }, |
|
568 { "a/b\\", "a/b" }, |
|
569 { "c\\\\/", "c" }, |
|
570 { "//\\", "/" }, |
|
571 #endif |
|
572 #ifdef G_WITH_CYGWIN |
|
573 { "//server/share///x", "//server/share" }, |
|
574 #endif |
|
575 { ".", "." }, |
|
576 { "..", "." }, |
|
577 { "", "." }, |
|
578 }; |
|
579 guint n_dirname_checks = G_N_ELEMENTS (dirname_checks); |
|
580 |
|
581 struct { |
|
582 gchar *filename; |
|
583 gchar *without_root; |
|
584 } skip_root_checks[] = { |
|
585 { "/", "" }, |
|
586 { "//", "" }, |
|
587 { "/foo", "foo" }, |
|
588 { "//foo", "foo" }, |
|
589 { "a/b", NULL }, |
|
590 #ifdef G_OS_WIN32 |
|
591 { "\\", "" }, |
|
592 { "\\foo", "foo" }, |
|
593 { "\\\\server\\foo", "" }, |
|
594 { "\\\\server\\foo\\bar", "bar" }, |
|
595 { "a\\b", NULL }, |
|
596 #endif |
|
597 #ifdef G_WITH_CYGWIN |
|
598 { "//server/share///x", "//x" }, |
|
599 #endif |
|
600 { ".", NULL }, |
|
601 { "", NULL }, |
|
602 }; |
|
603 guint n_skip_root_checks = G_N_ELEMENTS (skip_root_checks); |
|
604 |
|
605 #ifndef G_DISABLE_ASSERT |
|
606 guint16 gu16t1 = 0x44afU, gu16t2 = 0xaf44U; |
|
607 guint32 gu32t1 = 0x02a7f109U, gu32t2 = 0x09f1a702U; |
|
608 guint64 gu64t1 = G_GINT64_CONSTANT(0x1d636b02300a7aa7U), |
|
609 gu64t2 = G_GINT64_CONSTANT(0xa77a0a30026b631dU); |
|
610 #endif |
|
611 const char hello[] = "Hello, World"; |
|
612 const int hellolen = sizeof (hello) - 1; |
|
613 int fd; |
|
614 char template[32]; |
|
615 GError *error; |
|
616 char *name_used; |
|
617 #ifdef G_OS_WIN32 |
|
618 /* Can't calculate GLib DLL name at runtime. */ |
|
619 gchar *glib_dll = "libglib-2.0-0.dll"; |
|
620 #endif |
|
621 #ifdef G_WITH_CYGWIN |
|
622 gchar *glib_dll = "cygglib-2.0-0.dll"; |
|
623 #endif |
|
624 |
|
625 gchar hostname[256]; |
|
626 |
|
627 #ifdef __SYMBIAN32__ |
|
628 g_log_set_handler (NULL, G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, &mrtLogHandler, NULL); |
|
629 g_set_print_handler(mrtPrintHandler); |
|
630 #endif /*__SYMBIAN32__*/ |
|
631 |
|
632 #ifndef __SYMBIAN32__ |
|
633 g_print ("TestGLib v%u.%u.%u (i:%u b:%u)\n", |
|
634 glib_major_version, |
|
635 glib_minor_version, |
|
636 glib_micro_version, |
|
637 glib_interface_age, |
|
638 glib_binary_age); |
|
639 #endif /* __SYMBIAN32__ */ |
|
640 |
|
641 string = g_get_current_dir (); |
|
642 g_assert(!strcmp(string,"C:\\Private\\e000002c")); |
|
643 |
|
644 string = (char *)g_get_user_name (); |
|
645 g_assert(!strcmp(string,"root")); |
|
646 |
|
647 string = (char *)g_get_real_name (); |
|
648 g_assert(!strcmp(string,"Unknown")); |
|
649 |
|
650 string = (char *)g_get_host_name (); |
|
651 gethostname(hostname,256); |
|
652 g_assert(!strcmp(string,hostname)); |
|
653 |
|
654 s = g_get_home_dir (); |
|
655 g_assert(!strcmp(s,"C:\\Private\\e000002c") && "Wrong value for g_get_home_dir()"); |
|
656 s = g_get_user_data_dir (); |
|
657 g_assert(!strcmp(s,"C:\\Private\\e000002c\\tmp") || !strcmp(s,"C:\\Private\\e000002c")); |
|
658 s = g_get_user_config_dir (); |
|
659 g_assert(!strcmp(s,"C:\\Private\\e000002c\\tmp") || !strcmp(s,"C:\\Private\\e000002c")); |
|
660 s = g_get_user_cache_dir (); |
|
661 g_assert(!strcmp(s,"C:\\Private\\e000002c\\tmp") || !strcmp(s,"C:\\Private\\e000002c")); |
|
662 sv = (gchar **) g_get_system_data_dirs (); |
|
663 g_assert(!strcmp(sv[0],"C:\\Private\\e000002c\\tmp") || !strcmp(sv[0],"C:\\Private\\e000002c")); |
|
664 g_assert(sv[1] == NULL); |
|
665 |
|
666 sv = (gchar **) g_get_system_config_dirs (); |
|
667 g_assert(!strcmp(sv[0],"C:\\Private\\e000002c\\tmp") || !strcmp(sv[0],"C:\\Private\\e000002c")); |
|
668 g_assert(sv[1] == NULL); |
|
669 |
|
670 string = (char *)g_get_tmp_dir (); |
|
671 g_assert(!strcmp(string,"C:\\Private\\e000002c\\tmp") && "Wrong value for g_get_tmp_dir()"); |
|
672 |
|
673 sv = (gchar **) g_get_language_names (); |
|
674 g_assert(!strcmp(sv[0],"C")); |
|
675 g_assert(!strcmp(sv[1],"C")); |
|
676 g_assert(sv[2] == NULL); |
|
677 |
|
678 /* type sizes */ |
|
679 TEST (NULL, sizeof (gint8) == 1); |
|
680 |
|
681 TEST (NULL, sizeof (gint16) == 2); |
|
682 |
|
683 TEST (NULL, sizeof (gint32) == 4); |
|
684 |
|
685 TEST (NULL, sizeof (gint64) == 8); |
|
686 |
|
687 |
|
688 string = g_path_get_basename (G_DIR_SEPARATOR_S "foo" G_DIR_SEPARATOR_S "dir" G_DIR_SEPARATOR_S); |
|
689 g_assert (strcmp (string, "dir") == 0); |
|
690 g_free (string); |
|
691 |
|
692 string = g_path_get_basename (G_DIR_SEPARATOR_S "foo" G_DIR_SEPARATOR_S "file"); |
|
693 g_assert (strcmp (string, "file") == 0); |
|
694 g_free (string); |
|
695 |
|
696 #ifdef G_OS_WIN32 |
|
697 string = g_path_get_basename ("/foo/dir/"); |
|
698 g_assert (strcmp (string, "dir") == 0); |
|
699 g_free (string); |
|
700 string = g_path_get_basename ("/foo/file"); |
|
701 g_assert (strcmp (string, "file") == 0); |
|
702 g_free (string); |
|
703 #endif |
|
704 |
|
705 //g_print ("checking g_path_get_dirname()..."); |
|
706 for (i = 0; i < n_dirname_checks; i++) |
|
707 { |
|
708 gchar *dirname; |
|
709 |
|
710 dirname = g_path_get_dirname (dirname_checks[i].filename); |
|
711 if (strcmp (dirname, dirname_checks[i].dirname) != 0) |
|
712 { |
|
713 g_print ("\nfailed for \"%s\"==\"%s\" (returned: \"%s\")\n", |
|
714 dirname_checks[i].filename, |
|
715 dirname_checks[i].dirname, |
|
716 dirname); |
|
717 g_assert(FALSE && "testglib"); |
|
718 n_dirname_checks = 0; |
|
719 } |
|
720 g_free (dirname); |
|
721 } |
|
722 g_assert(n_dirname_checks != 0 && "g_path_get_dirname failed" ); |
|
723 |
|
724 //g_print ("checking g_path_skip_root()..."); |
|
725 for (i = 0; i < n_skip_root_checks; i++) |
|
726 { |
|
727 const gchar *skipped; |
|
728 |
|
729 skipped = g_path_skip_root (skip_root_checks[i].filename); |
|
730 if ((skipped && !skip_root_checks[i].without_root) || |
|
731 (!skipped && skip_root_checks[i].without_root) || |
|
732 ((skipped && skip_root_checks[i].without_root) && |
|
733 strcmp (skipped, skip_root_checks[i].without_root))) |
|
734 { |
|
735 g_print ("\nfailed for \"%s\"==\"%s\" (returned: \"%s\")\n", |
|
736 skip_root_checks[i].filename, |
|
737 (skip_root_checks[i].without_root ? |
|
738 skip_root_checks[i].without_root : "<NULL>"), |
|
739 (skipped ? skipped : "<NULL>")); |
|
740 g_assert(FALSE && "testglib"); |
|
741 n_skip_root_checks = 0; |
|
742 } |
|
743 } |
|
744 g_assert(n_skip_root_checks != 0 && "g_path_skip_root failed" ); |
|
745 |
|
746 g_assert(test_g_mkdir_with_parents()); |
|
747 //g_print ("checking doubly linked lists..."); |
|
748 |
|
749 list = NULL; |
|
750 for (i = 0; i < 10; i++) |
|
751 list = g_list_append (list, &nums[i]); |
|
752 list = g_list_reverse (list); |
|
753 |
|
754 for (i = 0; i < 10; i++) |
|
755 { |
|
756 t = g_list_nth (list, i); |
|
757 if (*((gint*) t->data) != (9 - i)) |
|
758 g_error ("Regular insert failed"); |
|
759 } |
|
760 |
|
761 for (i = 0; i < 10; i++) |
|
762 if(g_list_position(list, g_list_nth (list, i)) != i) |
|
763 g_error("g_list_position does not seem to be the inverse of g_list_nth\n"); |
|
764 |
|
765 g_list_free (list); |
|
766 list = NULL; |
|
767 |
|
768 for (i = 0; i < 10; i++) |
|
769 list = g_list_insert_sorted (list, &morenums[i], my_list_compare_one); |
|
770 |
|
771 for (i = 0; i < 10; i++) |
|
772 { |
|
773 t = g_list_nth (list, i); |
|
774 if (*((gint*) t->data) != i) |
|
775 g_error ("Sorted insert failed"); |
|
776 } |
|
777 |
|
778 g_list_free (list); |
|
779 list = NULL; |
|
780 |
|
781 for (i = 0; i < 10; i++) |
|
782 list = g_list_insert_sorted (list, &morenums[i], my_list_compare_two); |
|
783 |
|
784 for (i = 0; i < 10; i++) |
|
785 { |
|
786 t = g_list_nth (list, i); |
|
787 if (*((gint*) t->data) != (9 - i)) |
|
788 g_error ("Sorted insert failed"); |
|
789 } |
|
790 |
|
791 g_list_free (list); |
|
792 list = NULL; |
|
793 |
|
794 for (i = 0; i < 10; i++) |
|
795 list = g_list_prepend (list, &morenums[i]); |
|
796 |
|
797 list = g_list_sort (list, my_list_compare_two); |
|
798 |
|
799 |
|
800 for (i = 0; i < 10; i++) |
|
801 { |
|
802 t = g_list_nth (list, i); |
|
803 if (*((gint*) t->data) != (9 - i)) |
|
804 g_error ("Merge sort failed"); |
|
805 } |
|
806 |
|
807 g_list_free (list); |
|
808 //g_print ("ok\n"); |
|
809 //g_print ("checking singly linked lists..."); |
|
810 |
|
811 slist = NULL; |
|
812 for (i = 0; i < 10; i++) |
|
813 slist = g_slist_append (slist, &nums[i]); |
|
814 slist = g_slist_reverse (slist); |
|
815 |
|
816 for (i = 0; i < 10; i++) |
|
817 { |
|
818 st = g_slist_nth (slist, i); |
|
819 if (*((gint*) st->data) != (9 - i)) |
|
820 g_error ("failed"); |
|
821 } |
|
822 |
|
823 g_slist_free (slist); |
|
824 slist = NULL; |
|
825 |
|
826 for (i = 0; i < 10; i++) |
|
827 slist = g_slist_insert_sorted (slist, &morenums[i], my_list_compare_one); |
|
828 |
|
829 for (i = 0; i < 10; i++) |
|
830 { |
|
831 st = g_slist_nth (slist, i); |
|
832 if (*((gint*) st->data) != i) |
|
833 g_error ("Sorted insert failed"); |
|
834 } |
|
835 |
|
836 g_slist_free(slist); |
|
837 slist = NULL; |
|
838 |
|
839 for (i = 0; i < 10; i++) |
|
840 slist = g_slist_insert_sorted (slist, &morenums[i], my_list_compare_two); |
|
841 |
|
842 |
|
843 for (i = 0; i < 10; i++) |
|
844 { |
|
845 st = g_slist_nth (slist, i); |
|
846 if (*((gint*) st->data) != (9 - i)) |
|
847 g_error("Sorted insert failed"); |
|
848 } |
|
849 |
|
850 g_slist_free(slist); |
|
851 slist = NULL; |
|
852 |
|
853 for (i = 0; i < 10; i++) |
|
854 slist = g_slist_prepend (slist, &morenums[i]); |
|
855 |
|
856 slist = g_slist_sort (slist, my_list_compare_two); |
|
857 |
|
858 |
|
859 for (i = 0; i < 10; i++) |
|
860 { |
|
861 st = g_slist_nth (slist, i); |
|
862 if (*((gint*) st->data) != (9 - i)) |
|
863 g_error("Sorted insert failed"); |
|
864 } |
|
865 |
|
866 g_slist_free(slist); |
|
867 //g_print ("ok\n"); |
|
868 //g_print ("checking binary trees...\n"); |
|
869 |
|
870 tree = g_tree_new (my_compare); |
|
871 i = 0; |
|
872 for (j = 0; j < 10; j++, i++) |
|
873 { |
|
874 chars[i] = '0' + j; |
|
875 g_tree_insert (tree, &chars[i], &chars[i]); |
|
876 } |
|
877 for (j = 0; j < 26; j++, i++) |
|
878 { |
|
879 chars[i] = 'A' + j; |
|
880 g_tree_insert (tree, &chars[i], &chars[i]); |
|
881 } |
|
882 for (j = 0; j < 26; j++, i++) |
|
883 { |
|
884 chars[i] = 'a' + j; |
|
885 g_tree_insert (tree, &chars[i], &chars[i]); |
|
886 } |
|
887 |
|
888 g_assert(g_tree_height(tree) == 6); |
|
889 g_assert(g_tree_nnodes(tree) == 62); |
|
890 |
|
891 for (i = 0; i < 10; i++) |
|
892 g_tree_remove (tree, &chars[i]); |
|
893 |
|
894 g_assert(g_tree_height(tree) == 6); |
|
895 g_assert(g_tree_nnodes(tree) == 52); |
|
896 |
|
897 //g_print ("tree: "); |
|
898 //g_tree_foreach (tree, my_traverse, NULL); |
|
899 //g_print ("\n"); |
|
900 |
|
901 //g_print ("ok\n"); |
|
902 /* check n-way trees */ |
|
903 g_node_test (); |
|
904 |
|
905 //g_print ("checking mem chunks..."); |
|
906 mem_chunk = g_mem_chunk_new ("test mem chunk", 50, 100, G_ALLOC_AND_FREE); |
|
907 |
|
908 #ifdef __SYMBIAN32__ |
|
909 for (i = 0; i < 6000 ; i++) |
|
910 { |
|
911 mem[i] = g_chunk_new (gchar, mem_chunk); |
|
912 |
|
913 for (j = 0; j < 50; j++) |
|
914 mem[i][j] = i * j; |
|
915 } |
|
916 #else |
|
917 for (i = 0; i < 10000 ; i++) |
|
918 { |
|
919 mem[i] = g_chunk_new (gchar, mem_chunk); |
|
920 |
|
921 for (j = 0; j < 50; j++) |
|
922 mem[i][j] = i * j; |
|
923 } |
|
924 #endif |
|
925 |
|
926 |
|
927 #ifdef __SYMBIAN32__ |
|
928 for (i = 0; i < 6000 ; i++) |
|
929 { |
|
930 g_mem_chunk_free (mem_chunk, mem[i]); |
|
931 } |
|
932 #else |
|
933 for (i = 0; i < i 10000; i++) |
|
934 { |
|
935 g_mem_chunk_free (mem_chunk, mem[i]); |
|
936 } |
|
937 #endif |
|
938 //g_print ("checking hash tables..."); |
|
939 |
|
940 hash_table = g_hash_table_new (my_hash, my_hash_equal); |
|
941 |
|
942 #ifdef __SYMBIAN32__ |
|
943 for (i = 0; i < 3000 ; i++) |
|
944 { |
|
945 array[i] = i; |
|
946 g_hash_table_insert (hash_table, &array[i], &array[i]); |
|
947 } |
|
948 #else |
|
949 for (i = 0; i < i 10000 ; i++) |
|
950 { |
|
951 array[i] = i; |
|
952 g_hash_table_insert (hash_table, &array[i], &array[i]); |
|
953 } |
|
954 #endif |
|
955 |
|
956 pvalue = g_hash_table_find (hash_table, find_first_that, &value); |
|
957 if (*pvalue != value) |
|
958 { |
|
959 |
|
960 g_print("g_hash_table_find failed"); |
|
961 g_assert(FALSE && "testglib"); |
|
962 } |
|
963 g_hash_table_foreach (hash_table, my_hash_callback, NULL); |
|
964 |
|
965 #ifdef __SYMBIAN32__ |
|
966 for (i = 0; i < 3000 ; i++) |
|
967 if (array[i] == 0) |
|
968 g_print ("%d\n", i); |
|
969 #else |
|
970 for (i = 0; i < 10000; i++) |
|
971 if (array[i] == 0) |
|
972 g_print ("%d\n", i); |
|
973 #endif |
|
974 |
|
975 #ifdef __SYMBIAN32__ |
|
976 for (i = 0; i < 3000 ; i++) |
|
977 g_hash_table_remove (hash_table, &array[i]); |
|
978 #else |
|
979 for (i = 0; i < 10000; i++) |
|
980 g_hash_table_remove (hash_table, &array[i]); |
|
981 #endif |
|
982 |
|
983 #ifdef __SYMBIAN32__ |
|
984 for (i = 0; i < 3000 ; i++) |
|
985 { |
|
986 array[i] = i; |
|
987 g_hash_table_insert (hash_table, &array[i], &array[i]); |
|
988 } |
|
989 #else |
|
990 for (i = 0; i < 10000; i++) |
|
991 { |
|
992 array[i] = i; |
|
993 g_hash_table_insert (hash_table, &array[i], &array[i]); |
|
994 } |
|
995 #endif |
|
996 |
|
997 #ifdef __SYMBIAN32__ |
|
998 if (g_hash_table_foreach_remove (hash_table, my_hash_callback_remove, NULL) != 1500 || |
|
999 g_hash_table_size (hash_table) != 1500 ) |
|
1000 g_print ("bad!\n"); |
|
1001 #else |
|
1002 if (g_hash_table_foreach_remove (hash_table, my_hash_callback_remove, NULL) != 5000 || |
|
1003 g_hash_table_size (hash_table) != 5000) |
|
1004 g_print ("bad!\n"); |
|
1005 #endif |
|
1006 |
|
1007 |
|
1008 g_hash_table_foreach (hash_table, my_hash_callback_remove_test, NULL); |
|
1009 |
|
1010 |
|
1011 g_hash_table_destroy (hash_table); |
|
1012 |
|
1013 string_chunk = g_string_chunk_new (1024); |
|
1014 |
|
1015 #ifdef __SYMBIAN32__ |
|
1016 for (i = 0; i < 3000; i ++) |
|
1017 { |
|
1018 tmp_string = g_string_chunk_insert (string_chunk, "hi pete"); |
|
1019 |
|
1020 if (strcmp ("hi pete", tmp_string) != 0) |
|
1021 g_error ("string chunks are broken.\n"); |
|
1022 } |
|
1023 #else |
|
1024 for (i = 0; i < 100000; i ++) |
|
1025 { |
|
1026 tmp_string = g_string_chunk_insert (string_chunk, "hi pete"); |
|
1027 |
|
1028 if (strcmp ("hi pete", tmp_string) != 0) |
|
1029 g_error ("string chunks are broken.\n"); |
|
1030 } |
|
1031 #endif |
|
1032 |
|
1033 tmp_string_2 = g_string_chunk_insert_const (string_chunk, tmp_string); |
|
1034 |
|
1035 g_assert (tmp_string_2 != tmp_string && |
|
1036 strcmp(tmp_string_2, tmp_string) == 0); |
|
1037 |
|
1038 tmp_string = g_string_chunk_insert_const (string_chunk, tmp_string); |
|
1039 |
|
1040 g_assert (tmp_string_2 == tmp_string); |
|
1041 |
|
1042 g_string_chunk_free (string_chunk); |
|
1043 |
|
1044 //g_print ("ok\n"); |
|
1045 //g_print ("checking arrays..."); |
|
1046 garray = g_array_new (FALSE, FALSE, sizeof (gint)); |
|
1047 |
|
1048 #ifdef __SYMBIAN32__ |
|
1049 for (i = 0; i < 3000; i++) |
|
1050 g_array_append_val (garray, i); |
|
1051 #else |
|
1052 for (i = 0; i < 10000; i++) |
|
1053 g_array_append_val (garray, i); |
|
1054 #endif |
|
1055 |
|
1056 #ifdef __SYMBIAN32__ |
|
1057 for (i = 0; i < 3000 ; i++) |
|
1058 if (g_array_index (garray, gint, i) != i) |
|
1059 g_print ("uh oh: %d ( %d )\n", g_array_index (garray, gint, i), i); |
|
1060 #else |
|
1061 for (i = 0; i < i 10000; i++) |
|
1062 if (g_array_index (garray, gint, i) != i) |
|
1063 g_print ("uh oh: %d ( %d )\n", g_array_index (garray, gint, i), i); |
|
1064 #endif |
|
1065 |
|
1066 g_array_free (garray, TRUE); |
|
1067 |
|
1068 garray = g_array_new (FALSE, FALSE, sizeof (gint)); |
|
1069 for (i = 0; i < 100; i++) |
|
1070 g_array_prepend_val (garray, i); |
|
1071 |
|
1072 for (i = 0; i < 100; i++) |
|
1073 if (g_array_index (garray, gint, i) != (100 - i - 1)) |
|
1074 g_print ("uh oh: %d ( %d )\n", g_array_index (garray, gint, i), 100 - i - 1); |
|
1075 |
|
1076 g_array_free (garray, TRUE); |
|
1077 |
|
1078 //g_print ("ok\n"); |
|
1079 //g_print ("checking strings..."); |
|
1080 string1 = g_string_new ("hi pete!"); |
|
1081 string2 = g_string_new (""); |
|
1082 |
|
1083 g_assert (strcmp ("hi pete!", string1->str) == 0); |
|
1084 |
|
1085 for (i = 0; i < 10000; i++) |
|
1086 g_string_append_c (string1, 'a'+(i%26)); |
|
1087 |
|
1088 #ifdef __SYMBIAN32__ |
|
1089 g_string_printf (string2, "%s|%0100d|%s|%s|%0*d|%*.*f|%100.100f", |
|
1090 "this pete guy sure is a wuss, like he's the number ", |
|
1091 1, |
|
1092 " wuss. everyone agrees.\n", |
|
1093 string1->str, |
|
1094 10, 666, 15, 15, 666.666666666, 666.666666666); |
|
1095 #else |
|
1096 #ifndef G_OS_WIN32 |
|
1097 /* MSVC, mingw32 and LCC use the same run-time C library, which doesn't like |
|
1098 the %10000.10000f format... */ |
|
1099 g_string_printf (string2, "%s|%0100d|%s|%s|%0*d|%*.*f|%10000.10000f", |
|
1100 "this pete guy sure is a wuss, like he's the number ", |
|
1101 1, |
|
1102 " wuss. everyone agrees.\n", |
|
1103 string1->str, |
|
1104 10, 666, 15, 15, 666.666666666, 666.666666666); |
|
1105 #else |
|
1106 g_string_printf (string2, "%s|%0100d|%s|%s|%0*d|%*.*f|%100.100f", |
|
1107 "this pete guy sure is a wuss, like he's the number ", |
|
1108 1, |
|
1109 " wuss. everyone agrees.\n", |
|
1110 string1->str, |
|
1111 10, 666, 15, 15, 666.666666666, 666.666666666); |
|
1112 #endif |
|
1113 #endif /* __SYMBIAN32__ */ |
|
1114 |
|
1115 g_assert((gulong)string2->len == 10323); |
|
1116 g_string_free (string1, TRUE); |
|
1117 g_string_free (string2, TRUE); |
|
1118 |
|
1119 /* append */ |
|
1120 string1 = g_string_new ("firsthalf"); |
|
1121 g_string_append (string1, "lasthalf"); |
|
1122 g_assert (strcmp (string1->str, "firsthalflasthalf") == 0); |
|
1123 g_string_free (string1, TRUE); |
|
1124 |
|
1125 /* append_len */ |
|
1126 |
|
1127 string1 = g_string_new ("firsthalf"); |
|
1128 g_string_append_len (string1, "lasthalfjunkjunk", strlen ("lasthalf")); |
|
1129 g_assert (strcmp (string1->str, "firsthalflasthalf") == 0); |
|
1130 g_string_free (string1, TRUE); |
|
1131 |
|
1132 /* prepend */ |
|
1133 string1 = g_string_new ("lasthalf"); |
|
1134 g_string_prepend (string1, "firsthalf"); |
|
1135 g_assert (strcmp (string1->str, "firsthalflasthalf") == 0); |
|
1136 g_string_free (string1, TRUE); |
|
1137 |
|
1138 /* prepend_len */ |
|
1139 string1 = g_string_new ("lasthalf"); |
|
1140 g_string_prepend_len (string1, "firsthalfjunkjunk", strlen ("firsthalf")); |
|
1141 g_assert (strcmp (string1->str, "firsthalflasthalf") == 0); |
|
1142 g_string_free (string1, TRUE); |
|
1143 |
|
1144 /* insert */ |
|
1145 string1 = g_string_new ("firstlast"); |
|
1146 g_string_insert (string1, 5, "middle"); |
|
1147 g_assert (strcmp (string1->str, "firstmiddlelast") == 0); |
|
1148 g_string_free (string1, TRUE); |
|
1149 |
|
1150 /* insert with pos == end of the string */ |
|
1151 string1 = g_string_new ("firstmiddle"); |
|
1152 g_string_insert (string1, strlen ("firstmiddle"), "last"); |
|
1153 g_assert (strcmp (string1->str, "firstmiddlelast") == 0); |
|
1154 g_string_free (string1, TRUE); |
|
1155 |
|
1156 /* insert_len */ |
|
1157 |
|
1158 string1 = g_string_new ("firstlast"); |
|
1159 g_string_insert_len (string1, 5, "middlejunkjunk", strlen ("middle")); |
|
1160 g_assert (strcmp (string1->str, "firstmiddlelast") == 0); |
|
1161 g_string_free (string1, TRUE); |
|
1162 |
|
1163 /* insert_len with magic -1 pos for append */ |
|
1164 string1 = g_string_new ("first"); |
|
1165 g_string_insert_len (string1, -1, "lastjunkjunk", strlen ("last")); |
|
1166 g_assert (strcmp (string1->str, "firstlast") == 0); |
|
1167 g_string_free (string1, TRUE); |
|
1168 |
|
1169 /* insert_len with magic -1 len for strlen-the-string */ |
|
1170 string1 = g_string_new ("first"); |
|
1171 g_string_insert_len (string1, 5, "last", -1); |
|
1172 g_assert (strcmp (string1->str, "firstlast") == 0); |
|
1173 g_string_free (string1, TRUE); |
|
1174 |
|
1175 /* g_string_equal */ |
|
1176 string1 = g_string_new ("test"); |
|
1177 string2 = g_string_new ("te"); |
|
1178 g_assert (! g_string_equal(string1, string2)); |
|
1179 g_string_append (string2, "st"); |
|
1180 g_assert (g_string_equal(string1, string2)); |
|
1181 g_string_free (string1, TRUE); |
|
1182 g_string_free (string2, TRUE); |
|
1183 |
|
1184 /* Check handling of embedded ASCII 0 (NUL) characters in GString. */ |
|
1185 string1 = g_string_new ("fiddle"); |
|
1186 string2 = g_string_new ("fiddle"); |
|
1187 g_assert (g_string_equal(string1, string2)); |
|
1188 g_string_append_c(string1, '\0'); |
|
1189 g_assert (! g_string_equal(string1, string2)); |
|
1190 g_string_append_c(string2, '\0'); |
|
1191 g_assert (g_string_equal(string1, string2)); |
|
1192 g_string_append_c(string1, 'x'); |
|
1193 g_string_append_c(string2, 'y'); |
|
1194 g_assert (! g_string_equal(string1, string2)); |
|
1195 g_assert (string1->len == 8); |
|
1196 g_string_append(string1, "yzzy"); |
|
1197 g_assert (string1->len == 12); |
|
1198 g_assert ( memcmp(string1->str, "fiddle\0xyzzy", 13) == 0); |
|
1199 g_string_insert(string1, 1, "QED"); |
|
1200 g_assert ( memcmp(string1->str, "fQEDiddle\0xyzzy", 16) == 0); |
|
1201 g_string_free (string1, TRUE); |
|
1202 g_string_free (string2, TRUE); |
|
1203 |
|
1204 //g_print ("test positional printf formats (not supported): "); |
|
1205 string = g_strdup_printf ("%.*s%s", 5, "a", "b"); |
|
1206 tmp_string = g_strdup_printf ("%2$*1$s", 5, "c"); |
|
1207 g_assert(!strcmp(string,"ab")); |
|
1208 g_assert(!strcmp(tmp_string," c")); |
|
1209 g_free (tmp_string); |
|
1210 g_free (string); |
|
1211 |
|
1212 timer = g_timer_new (); |
|
1213 |
|
1214 g_timer_start (timer); |
|
1215 while (g_timer_elapsed (timer, NULL) < 3) |
|
1216 ; |
|
1217 |
|
1218 g_timer_stop (timer); |
|
1219 g_timer_destroy (timer); |
|
1220 |
|
1221 timer2 = g_timer_new (); |
|
1222 |
|
1223 timer = g_timer_new(); |
|
1224 g_usleep(G_USEC_PER_SEC); /* run timer for 1 second */ |
|
1225 g_timer_stop(timer); |
|
1226 |
|
1227 g_usleep(G_USEC_PER_SEC); /* wait for 1 second */ |
|
1228 |
|
1229 g_timer_continue(timer); |
|
1230 g_usleep(2*G_USEC_PER_SEC); /* run timer for 2 seconds */ |
|
1231 g_timer_stop(timer); |
|
1232 |
|
1233 g_usleep((3*G_USEC_PER_SEC)/2); /* wait for 1.5 seconds */ |
|
1234 |
|
1235 g_timer_continue(timer); |
|
1236 g_usleep(G_USEC_PER_SEC/5); /* run timer for 0.2 seconds */ |
|
1237 g_timer_stop(timer); |
|
1238 |
|
1239 g_usleep(4*G_USEC_PER_SEC); /* wait for 4 seconds */ |
|
1240 |
|
1241 g_timer_continue(timer); |
|
1242 g_usleep((29*G_USEC_PER_SEC)/5); /* run timer for 5.8 seconds */ |
|
1243 g_timer_stop(timer); |
|
1244 |
|
1245 elapsed = g_timer_elapsed (timer, &elapsed_usecs); |
|
1246 |
|
1247 if (elapsed > 8.8 && elapsed < 9.2); |
|
1248 |
|
1249 else |
|
1250 { |
|
1251 g_assert(FALSE && "testglib"); |
|
1252 g_print ("g_timer_continue ... ***** FAILED *****\n\n"); |
|
1253 g_print ("timer elapsed %d\n",elapsed); |
|
1254 } |
|
1255 g_timer_stop(timer2); |
|
1256 |
|
1257 elapsed = g_timer_elapsed(timer2, &elapsed_usecs); |
|
1258 |
|
1259 if (elapsed > (8.8+6.5) && elapsed < (9.2+6.5)); |
|
1260 |
|
1261 else |
|
1262 { |
|
1263 g_assert(FALSE && "testglib"); |
|
1264 g_print ("timer2 ... ***** FAILED *****\n\n"); |
|
1265 g_print ("timer2 elapsed %d\n",elapsed); |
|
1266 } |
|
1267 g_timer_destroy(timer); |
|
1268 g_timer_destroy(timer2); |
|
1269 |
|
1270 g_assert (g_ascii_strcasecmp ("FroboZZ", "frobozz") == 0); |
|
1271 g_assert (g_ascii_strcasecmp ("frobozz", "frobozz") == 0); |
|
1272 g_assert (g_ascii_strcasecmp ("frobozz", "FROBOZZ") == 0); |
|
1273 g_assert (g_ascii_strcasecmp ("FROBOZZ", "froboz") > 0); |
|
1274 g_assert (g_ascii_strcasecmp ("", "") == 0); |
|
1275 g_assert (g_ascii_strcasecmp ("!#%&/()", "!#%&/()") == 0); |
|
1276 g_assert (g_ascii_strcasecmp ("a", "b") < 0); |
|
1277 g_assert (g_ascii_strcasecmp ("a", "B") < 0); |
|
1278 g_assert (g_ascii_strcasecmp ("A", "b") < 0); |
|
1279 g_assert (g_ascii_strcasecmp ("A", "B") < 0); |
|
1280 g_assert (g_ascii_strcasecmp ("b", "a") > 0); |
|
1281 g_assert (g_ascii_strcasecmp ("b", "A") > 0); |
|
1282 g_assert (g_ascii_strcasecmp ("B", "a") > 0); |
|
1283 g_assert (g_ascii_strcasecmp ("B", "A") > 0); |
|
1284 |
|
1285 g_assert(g_strdup(NULL) == NULL); |
|
1286 string = g_strdup(GLIB_TEST_STRING); |
|
1287 g_assert(string != NULL); |
|
1288 g_assert(strcmp(string, GLIB_TEST_STRING) == 0); |
|
1289 g_free(string); |
|
1290 |
|
1291 string = g_strconcat(GLIB_TEST_STRING, NULL); |
|
1292 g_assert(string != NULL); |
|
1293 g_assert(strcmp(string, GLIB_TEST_STRING) == 0); |
|
1294 g_free(string); |
|
1295 string = g_strconcat(GLIB_TEST_STRING, GLIB_TEST_STRING, |
|
1296 GLIB_TEST_STRING, NULL); |
|
1297 g_assert(string != NULL); |
|
1298 g_assert(strcmp(string, GLIB_TEST_STRING GLIB_TEST_STRING |
|
1299 GLIB_TEST_STRING) == 0); |
|
1300 g_free(string); |
|
1301 |
|
1302 |
|
1303 /* The following is a torture test for strlcpy/strlcat, with lots of |
|
1304 * checking; normal users wouldn't use them this way! |
|
1305 */ |
|
1306 string = g_malloc (6); |
|
1307 *(string + 5) = 'Z'; /* guard value, shouldn't change during test */ |
|
1308 *string = 'q'; |
|
1309 g_assert (g_strlcpy(string, "" , 5) == 0); |
|
1310 g_assert ( *string == '\0' ); |
|
1311 *string = 'q'; |
|
1312 g_assert (g_strlcpy(string, "abc" , 5) == 3); |
|
1313 g_assert ( *(string + 3) == '\0' ); |
|
1314 g_assert (g_str_equal(string, "abc")); |
|
1315 g_assert (g_strlcpy(string, "abcd" , 5) == 4); |
|
1316 g_assert ( *(string + 4) == '\0' ); |
|
1317 g_assert ( *(string + 5) == 'Z' ); |
|
1318 g_assert (g_str_equal(string, "abcd")); |
|
1319 g_assert (g_strlcpy(string, "abcde" , 5) == 5); |
|
1320 g_assert ( *(string + 4) == '\0' ); |
|
1321 g_assert ( *(string + 5) == 'Z' ); |
|
1322 g_assert (g_str_equal(string, "abcd")); |
|
1323 g_assert (g_strlcpy(string, "abcdef" , 5) == 6); |
|
1324 g_assert ( *(string + 4) == '\0' ); |
|
1325 g_assert ( *(string + 5) == 'Z' ); |
|
1326 g_assert (g_str_equal(string, "abcd")); |
|
1327 *string = 'Y'; |
|
1328 *(string + 1)= '\0'; |
|
1329 g_assert (g_strlcpy(string, "Hello" , 0) == 5); |
|
1330 g_assert (*string == 'Y'); |
|
1331 *string = '\0'; |
|
1332 g_assert (g_strlcat(string, "123" , 5) == 3); |
|
1333 g_assert ( *(string + 3) == '\0' ); |
|
1334 g_assert (g_str_equal(string, "123")); |
|
1335 g_assert (g_strlcat(string, "" , 5) == 3); |
|
1336 g_assert ( *(string + 3) == '\0' ); |
|
1337 g_assert (g_str_equal(string, "123")); |
|
1338 g_assert (g_strlcat(string, "4", 5) == 4); |
|
1339 g_assert (g_str_equal(string, "1234")); |
|
1340 g_assert (g_strlcat(string, "5", 5) == 5); |
|
1341 g_assert ( *(string + 4) == '\0' ); |
|
1342 g_assert (g_str_equal(string, "1234")); |
|
1343 g_assert ( *(string + 5) == 'Z' ); |
|
1344 *string = 'Y'; |
|
1345 *(string + 1)= '\0'; |
|
1346 g_assert (g_strlcat(string, "123" , 0) == 3); |
|
1347 g_assert (*string == 'Y'); |
|
1348 |
|
1349 /* A few more tests, demonstrating more "normal" use */ |
|
1350 g_assert (g_strlcpy(string, "hi", 5) == 2); |
|
1351 g_assert (g_str_equal(string, "hi")); |
|
1352 g_assert (g_strlcat(string, "t", 5) == 3); |
|
1353 g_assert (g_str_equal(string, "hit")); |
|
1354 g_free(string); |
|
1355 |
|
1356 string = g_strdup_printf ("%05d %-5s", 21, "test"); |
|
1357 g_assert (string != NULL); |
|
1358 g_assert (strcmp(string, "00021 test ") == 0); |
|
1359 g_free (string); |
|
1360 |
|
1361 |
|
1362 /* g_debug (argv[0]); */ |
|
1363 |
|
1364 /* Relation tests */ |
|
1365 |
|
1366 relation = g_relation_new (2); |
|
1367 |
|
1368 g_relation_index (relation, 0, g_int_hash, g_int_equal); |
|
1369 g_relation_index (relation, 1, g_int_hash, g_int_equal); |
|
1370 |
|
1371 #ifdef __SYMBIAN32__ |
|
1372 for (i = 0; i < 250 ; i += 1) |
|
1373 data[i] = i; |
|
1374 #else |
|
1375 for (i = 0; i < 1024; i += 1) |
|
1376 data[i] = i; |
|
1377 #endif |
|
1378 |
|
1379 #ifdef __SYMBIAN32__ |
|
1380 for (i = 1; i < 250 ; i += 1) |
|
1381 { |
|
1382 g_relation_insert (relation, data + i, data + i + 1); |
|
1383 g_relation_insert (relation, data + i, data + i - 1); |
|
1384 } |
|
1385 #else |
|
1386 for (i = 1; i < 1023; i += 1) |
|
1387 { |
|
1388 g_relation_insert (relation, data + i, data + i + 1); |
|
1389 g_relation_insert (relation, data + i, data + i - 1); |
|
1390 } |
|
1391 #endif |
|
1392 |
|
1393 #ifdef __SYMBIAN32__ |
|
1394 for (i = 2; i < 249; i += 1) |
|
1395 { |
|
1396 g_assert (! g_relation_exists (relation, data + i, data + i)); |
|
1397 g_assert (! g_relation_exists (relation, data + i, data + i + 2)); |
|
1398 g_assert (! g_relation_exists (relation, data + i, data + i - 2)); |
|
1399 } |
|
1400 #else |
|
1401 for (i = 2; i < 1022; i += 1) |
|
1402 { |
|
1403 g_assert (! g_relation_exists (relation, data + i, data + i)); |
|
1404 g_assert (! g_relation_exists (relation, data + i, data + i + 2)); |
|
1405 g_assert (! g_relation_exists (relation, data + i, data + i - 2)); |
|
1406 } |
|
1407 #endif |
|
1408 |
|
1409 #ifdef __SYMBIAN32__ |
|
1410 for (i = 1; i < 250 ; i += 1) |
|
1411 { |
|
1412 g_assert (g_relation_exists (relation, data + i, data + i + 1)); |
|
1413 g_assert (g_relation_exists (relation, data + i, data + i - 1)); |
|
1414 } |
|
1415 #else |
|
1416 for (i = 1; i < 1023; i += 1) |
|
1417 { |
|
1418 g_assert (g_relation_exists (relation, data + i, data + i + 1)); |
|
1419 g_assert (g_relation_exists (relation, data + i, data + i - 1)); |
|
1420 } |
|
1421 #endif |
|
1422 |
|
1423 #ifdef __SYMBIAN32__ |
|
1424 for (i = 2; i < 249; i += 1) |
|
1425 { |
|
1426 g_assert (g_relation_count (relation, data + i, 0) == 2); |
|
1427 g_assert (g_relation_count (relation, data + i, 1) == 2); |
|
1428 } |
|
1429 #else |
|
1430 for (i = 2; i < 1022; i += 1) |
|
1431 { |
|
1432 g_assert (g_relation_count (relation, data + i, 0) == 2); |
|
1433 g_assert (g_relation_count (relation, data + i, 1) == 2); |
|
1434 } |
|
1435 #endif |
|
1436 |
|
1437 g_assert (g_relation_count (relation, data, 0) == 0); |
|
1438 |
|
1439 g_assert (g_relation_count (relation, data + 42, 0) == 2); |
|
1440 g_assert (g_relation_count (relation, data + 43, 1) == 2); |
|
1441 g_assert (g_relation_count (relation, data + 41, 1) == 2); |
|
1442 g_relation_delete (relation, data + 42, 0); |
|
1443 g_assert (g_relation_count (relation, data + 42, 0) == 0); |
|
1444 g_assert (g_relation_count (relation, data + 43, 1) == 1); |
|
1445 g_assert (g_relation_count (relation, data + 41, 1) == 1); |
|
1446 |
|
1447 tuples = g_relation_select (relation, data + 200, 0); |
|
1448 |
|
1449 g_assert (tuples->len == 2); |
|
1450 |
|
1451 |
|
1452 #ifdef __SYMBIAN32__ |
|
1453 g_assert (g_relation_exists (relation, data + 100, data + 101 )); |
|
1454 g_relation_delete (relation, data + 100 , 0); |
|
1455 g_assert (!g_relation_exists (relation, data + 100 , data + 101 )); |
|
1456 #else |
|
1457 g_assert (g_relation_exists (relation, data + 300, data + i 301)); |
|
1458 g_relation_delete (relation, data + 300, 0); |
|
1459 g_assert (!g_relation_exists (relation, data + 300, data + 301)); |
|
1460 #endif |
|
1461 |
|
1462 g_tuples_destroy (tuples); |
|
1463 |
|
1464 g_relation_destroy (relation); |
|
1465 |
|
1466 relation = NULL; |
|
1467 |
|
1468 gparray = g_ptr_array_new (); |
|
1469 |
|
1470 #ifdef __SYMBIAN32__ |
|
1471 for (i = 0; i < 4000; i++) |
|
1472 g_ptr_array_add (gparray, GINT_TO_POINTER (i)); |
|
1473 for (i = 0; i < 4000 ; i++) |
|
1474 if (g_ptr_array_index (gparray, i) != GINT_TO_POINTER (i)) |
|
1475 { |
|
1476 g_assert(FALSE && "testglib"); |
|
1477 g_print ("array fails: %p ( %p )\n", g_ptr_array_index (gparray, i), GINT_TO_POINTER (i)); |
|
1478 } |
|
1479 #else |
|
1480 for (i = 0; i < 10000; i++) |
|
1481 g_ptr_array_add (gparray, GINT_TO_POINTER (i)); |
|
1482 for (i = 0; i < 10000; i++) |
|
1483 if (g_ptr_array_index (gparray, i) != GINT_TO_POINTER (i)) |
|
1484 { |
|
1485 g_assert(FALSE && "testglib"); |
|
1486 g_print ("array fails: %p ( %p )\n", g_ptr_array_index (gparray, i), GINT_TO_POINTER (i)); |
|
1487 } |
|
1488 #endif |
|
1489 |
|
1490 g_ptr_array_free (gparray, TRUE); |
|
1491 |
|
1492 |
|
1493 gbarray = g_byte_array_new (); |
|
1494 |
|
1495 #ifdef __SYMBIAN32__ |
|
1496 for (i = 0; i < 4000 ; i++) |
|
1497 g_byte_array_append (gbarray, (guint8*) "abcd", 4); |
|
1498 |
|
1499 for (i = 0; i < 4000 ; i++) |
|
1500 { |
|
1501 g_assert (gbarray->data[4*i] == 'a'); |
|
1502 g_assert (gbarray->data[4*i+1] == 'b'); |
|
1503 g_assert (gbarray->data[4*i+2] == 'c'); |
|
1504 g_assert (gbarray->data[4*i+3] == 'd'); |
|
1505 } |
|
1506 #else |
|
1507 for (i = 0; i < 10000; i++) |
|
1508 g_byte_array_append (gbarray, (guint8*) "abcd", 4); |
|
1509 |
|
1510 for (i = 0; i < 10000; i++) |
|
1511 { |
|
1512 g_assert (gbarray->data[4*i] == 'a'); |
|
1513 g_assert (gbarray->data[4*i+1] == 'b'); |
|
1514 g_assert (gbarray->data[4*i+2] == 'c'); |
|
1515 g_assert (gbarray->data[4*i+3] == 'd'); |
|
1516 } |
|
1517 #endif |
|
1518 |
|
1519 g_byte_array_free (gbarray, TRUE); |
|
1520 |
|
1521 string = NULL; |
|
1522 |
|
1523 g_assert (GUINT16_SWAP_LE_BE (gu16t1) == gu16t2); |
|
1524 g_assert (GUINT32_SWAP_LE_BE (gu32t1) == gu32t2); |
|
1525 g_assert (GUINT64_SWAP_LE_BE (gu64t1) == gu64t2); |
|
1526 |
|
1527 //g_print ("ok\n"); |
|
1528 g_get_charset ((G_CONST_RETURN char**)&charset); |
|
1529 g_assert(!strcmp(charset,"US-ASCII")); |
|
1530 |
|
1531 #ifdef G_PLATFORM_WIN32 |
|
1532 g_print ("current locale: %s\n", g_win32_getlocale ()); |
|
1533 g_print ("GLib DLL name tested for: %s\n", glib_dll); |
|
1534 |
|
1535 g_print ("GLib installation directory, from Registry entry for %s if available: %s\n", |
|
1536 GETTEXT_PACKAGE, |
|
1537 g_win32_get_package_installation_directory (GETTEXT_PACKAGE, NULL)); |
|
1538 g_print ("Ditto, or from GLib DLL name: %s\n", |
|
1539 g_win32_get_package_installation_directory (GETTEXT_PACKAGE, glib_dll)); |
|
1540 g_print ("Ditto, only from GLib DLL name: %s\n", |
|
1541 g_win32_get_package_installation_directory (NULL, glib_dll)); |
|
1542 g_print ("locale subdirectory of GLib installation directory: %s\n", |
|
1543 g_win32_get_package_installation_subdirectory (NULL, glib_dll, "lib\\locale")); |
|
1544 g_print ("GTK+ 2.0 installation directory, if available: %s\n", |
|
1545 g_win32_get_package_installation_directory ("gtk20", NULL)); |
|
1546 |
|
1547 g_print ("found more.com as %s\n", g_find_program_in_path ("more.com")); |
|
1548 g_print ("found regedit as %s\n", g_find_program_in_path ("regedit")); |
|
1549 |
|
1550 g_print ("a Win32 error message: %s\n", g_win32_error_message (2)); |
|
1551 |
|
1552 #endif |
|
1553 |
|
1554 strcpy (template, "fooXXXXXX"); |
|
1555 fd = g_mkstemp (template); |
|
1556 g_assert(fd != -1); |
|
1557 |
|
1558 i = write (fd, hello, hellolen); |
|
1559 g_assert(i != -1); |
|
1560 |
|
1561 lseek (fd, 0, 0); |
|
1562 i = read (fd, chars, sizeof (chars)); |
|
1563 g_assert(i != -1); |
|
1564 |
|
1565 chars[i] = 0; |
|
1566 g_assert(!strcmp(chars, hello)); |
|
1567 |
|
1568 close (fd); |
|
1569 remove (template); |
|
1570 |
|
1571 error = NULL; |
|
1572 strcpy (template, "zap" G_DIR_SEPARATOR_S "barXXXXXX"); |
|
1573 fd = g_file_open_tmp (template, &name_used, &error); |
|
1574 |
|
1575 g_assert(fd == -1); |
|
1576 |
|
1577 close (fd); |
|
1578 g_clear_error (&error); |
|
1579 |
|
1580 #ifdef G_OS_WIN32 |
|
1581 strcpy (template, "zap/barXXXXXX"); |
|
1582 fd = g_file_open_tmp (template, &name_used, &error); |
|
1583 if (fd != -1) |
|
1584 g_print ("g_file_open_tmp works even if template contains '/'\n"); |
|
1585 else |
|
1586 g_print ("g_file_open_tmp correctly returns error: %s\n", |
|
1587 error->message); |
|
1588 close (fd); |
|
1589 g_clear_error (&error); |
|
1590 #endif |
|
1591 |
|
1592 strcpy (template, "zapXXXXXX"); |
|
1593 fd = g_file_open_tmp (template, &name_used, &error); |
|
1594 |
|
1595 g_assert(fd != -1); |
|
1596 |
|
1597 close (fd); |
|
1598 g_clear_error (&error); |
|
1599 remove (name_used); |
|
1600 |
|
1601 fd = g_file_open_tmp (NULL, &name_used, &error); |
|
1602 |
|
1603 g_assert(fd != -1); |
|
1604 |
|
1605 close (fd); |
|
1606 g_clear_error (&error); |
|
1607 remove (name_used); |
|
1608 |
|
1609 #ifdef __SYMBIAN32__ |
|
1610 testResultXml("testglib"); |
|
1611 #endif /* EMULATOR */ |
|
1612 return 0; |
|
1613 } |
|
1614 |