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