introduce an ENUMPREFIX substitution.
[platform/upstream/glib.git] / tests / strfunc-test.c
1 /* GLIB - Library of useful routines for C programming
2  * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
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 #undef G_DISABLE_ASSERT
28 #undef G_LOG_DOMAIN
29
30 #include <stdio.h>
31 #include <string.h>
32 #include "glib.h"
33 #include <stdarg.h>
34 #include <ctype.h>
35
36 static gboolean any_failed = FALSE;
37 static gboolean failed = FALSE;
38
39 #define TEST(m,cond)    G_STMT_START { failed = !(cond); \
40 if (failed) \
41   { if (!m) \
42       g_print ("(%s:%d) failed for: %s\n", __FILE__, __LINE__, ( # cond )); \
43     else \
44       g_print ("(%s:%d) failed for: %s: (%s)\n", __FILE__, __LINE__, ( # cond ), m ? (gchar*)m : ""); \
45     fflush (stdout); \
46     any_failed = TRUE; \
47   } \
48 } G_STMT_END
49
50 #define TEST_FAILED(message) \
51   G_STMT_START { g_print ("Error: "); g_print message; g_print ("\n"); any_failed = TRUE; } G_STMT_END
52
53 #define GLIB_TEST_STRING "el dorado "
54
55 static gboolean
56 strv_check (gchar **strv, ...)
57 {
58   gboolean ok = TRUE;
59   gint i = 0;
60   va_list list;
61
62   va_start (list, strv);
63   while (ok)
64     {
65       const gchar *str = va_arg (list, const char *);
66       if (strv[i] == NULL)
67         {
68           ok = str == NULL;
69           break;
70         }
71       if (str == NULL)
72         ok = FALSE;
73       else if (strcmp (strv[i], str) != 0)
74         ok = FALSE;
75       i++;
76     }
77   va_end (list);
78
79   g_strfreev (strv);
80
81   return ok;
82 }
83
84 static gboolean
85 str_check (gchar *str,
86            gchar *expected)
87 {
88   gboolean ok = (strcmp (str, expected) == 0);
89
90   g_free (str);
91
92   return ok;
93 }
94
95 static gboolean
96 strchomp_check (gchar *str,
97                 gchar *expected)
98 {
99   gchar *tmp = strdup (str);
100   gboolean ok;
101
102   g_strchomp (tmp);
103   ok = (strcmp (tmp, expected) == 0);
104   g_free (tmp);
105
106   return ok;
107 }
108
109 #define FOR_ALL_CTYPE(macro)    \
110         macro(isalnum)          \
111         macro(isalpha)          \
112         macro(iscntrl)          \
113         macro(isdigit)          \
114         macro(isgraph)          \
115         macro(islower)          \
116         macro(isprint)          \
117         macro(ispunct)          \
118         macro(isspace)          \
119         macro(isupper)          \
120         macro(isxdigit)
121
122 #define DEFINE_CALL_CTYPE(function)             \
123         static int                              \
124         call_##function (int c)                 \
125         {                                       \
126                 return function (c);            \
127         }
128
129 #define DEFINE_CALL_G_ASCII_CTYPE(function)     \
130         static gboolean                         \
131         call_g_ascii_##function (gchar c)       \
132         {                                       \
133                 return g_ascii_##function (c);  \
134         }
135
136 FOR_ALL_CTYPE (DEFINE_CALL_CTYPE)
137 FOR_ALL_CTYPE (DEFINE_CALL_G_ASCII_CTYPE)
138
139 static void
140 test_is_function (const char *name,
141                   gboolean (* ascii_function) (gchar),
142                   int (* c_library_function) (int),
143                   gboolean (* unicode_function) (gunichar))
144 {
145   int c;
146
147   for (c = 0; c <= 0x7F; c++)
148     {
149       gboolean ascii_result = ascii_function ((gchar)c);
150       gboolean c_library_result = c_library_function (c) != 0;
151       gboolean unicode_result = unicode_function ((gunichar) c);
152       if (ascii_result != c_library_result && c != '\v')
153         TEST_FAILED (("g_ascii_%s returned %d and %s returned %d for 0x%X",
154                       name, ascii_result, name, c_library_result, c));
155       if (ascii_result != unicode_result)
156         TEST_FAILED (("g_ascii_%s returned %d and g_unichar_%s returned %d for 0x%X",
157                       name, ascii_result, name, unicode_result, c));
158     }
159   for (c = 0x80; c <= 0xFF; c++)
160     {
161       gboolean ascii_result = ascii_function ((gchar)c);
162       if (ascii_result)
163         TEST_FAILED (("g_ascii_%s returned TRUE for 0x%X",
164                       name, c));
165     }
166 }
167
168 static void
169 test_to_function (const char *name,
170                   gchar (* ascii_function) (gchar),
171                   int (* c_library_function) (int),
172                   gunichar (* unicode_function) (gunichar))
173 {
174   int c;
175
176   for (c = 0; c <= 0x7F; c++)
177     {
178       int ascii_result = (guchar) ascii_function ((gchar) c);
179       int c_library_result = c_library_function (c);
180       int unicode_result = unicode_function ((gunichar) c);
181       if (ascii_result != c_library_result)
182         TEST_FAILED (("g_ascii_%s returned 0x%X and %s returned 0x%X for 0x%X",
183                       name, ascii_result, name, c_library_result, c));
184       if (ascii_result != unicode_result)
185         TEST_FAILED (("g_ascii_%s returned 0x%X and g_unichar_%s returned 0x%X for 0x%X",
186                       name, ascii_result, name, unicode_result, c));
187     }
188   for (c = 0x80; c <= 0xFF; c++)
189     {
190       int ascii_result = (guchar) ascii_function ((gchar) c);
191       if (ascii_result != c)
192         TEST_FAILED (("g_ascii_%s returned 0x%X for 0x%X",
193                       name, ascii_result, c));
194     }
195 }
196
197 static void
198 test_digit_function (const char *name,
199                      int (* ascii_function) (gchar),
200                      int (* unicode_function) (gunichar))
201 {
202   int c;
203
204   for (c = 0; c <= 0x7F; c++)
205     {
206       int ascii_result = ascii_function ((gchar) c);
207       int unicode_result = unicode_function ((gunichar) c);
208       if (ascii_result != unicode_result)
209         TEST_FAILED (("g_ascii_%s_value returned %d and g_unichar_%s_value returned %d for 0x%X",
210                       name, ascii_result, name, unicode_result, c));
211     }
212   for (c = 0x80; c <= 0xFF; c++)
213     {
214       int ascii_result = ascii_function ((gchar) c);
215       if (ascii_result != -1)
216         TEST_FAILED (("g_ascii_%s_value returned %d for 0x%X",
217                       name, ascii_result, c));
218     }
219 }
220
221 int
222 main (int   argc,
223       char *argv[])
224 {
225   gchar *string;
226   gchar *vec[] = { "Foo", "Bar", NULL };
227   gchar **copy;
228   gchar *args[10];
229   
230   TEST (NULL, g_ascii_strcasecmp ("FroboZZ", "frobozz") == 0);
231   TEST (NULL, g_ascii_strcasecmp ("frobozz", "frobozz") == 0);
232   TEST (NULL, g_ascii_strcasecmp ("frobozz", "FROBOZZ") == 0);
233   TEST (NULL, g_ascii_strcasecmp ("FROBOZZ", "froboz") != 0);
234   TEST (NULL, g_ascii_strcasecmp ("", "") == 0);
235   TEST (NULL, g_ascii_strcasecmp ("!#%&/()", "!#%&/()") == 0);
236   TEST (NULL, g_ascii_strcasecmp ("a", "b") < 0);
237   TEST (NULL, g_ascii_strcasecmp ("a", "B") < 0);
238   TEST (NULL, g_ascii_strcasecmp ("A", "b") < 0);
239   TEST (NULL, g_ascii_strcasecmp ("A", "B") < 0);
240   TEST (NULL, g_ascii_strcasecmp ("b", "a") > 0);
241   TEST (NULL, g_ascii_strcasecmp ("b", "A") > 0);
242   TEST (NULL, g_ascii_strcasecmp ("B", "a") > 0);
243   TEST (NULL, g_ascii_strcasecmp ("B", "A") > 0);
244
245   TEST (NULL, g_strdup (NULL) == NULL);
246   string = g_strdup (GLIB_TEST_STRING);
247   TEST (NULL, string != NULL);
248   TEST (NULL, strcmp (string, GLIB_TEST_STRING) == 0);
249   g_free(string);
250   
251   string = g_strconcat (GLIB_TEST_STRING, NULL);
252   TEST (NULL, string != NULL);
253   TEST (NULL, strcmp (string, GLIB_TEST_STRING) == 0);
254   g_free(string);
255   
256   string = g_strconcat (GLIB_TEST_STRING, GLIB_TEST_STRING, 
257                         GLIB_TEST_STRING, NULL);
258   TEST (NULL, string != NULL);
259   TEST (NULL, strcmp (string, GLIB_TEST_STRING GLIB_TEST_STRING
260                       GLIB_TEST_STRING) == 0);
261   g_free(string);
262   
263   string = g_strdup_printf ("%05d %-5s", 21, "test");
264   TEST (NULL, string != NULL);
265   TEST (NULL, strcmp(string, "00021 test ") == 0);
266   g_free (string);
267   
268   TEST (NULL, strcmp
269         (g_strcompress ("abc\\\\\\\"\\b\\f\\n\\r\\t\\003\\177\\234\\313\\12345z"),
270          "abc\\\"\b\f\n\r\t\003\177\234\313\12345z") == 0);
271   TEST (NULL, strcmp (g_strescape("abc\\\"\b\f\n\r\t\003\177\234\313", NULL),
272                       "abc\\\\\\\"\\b\\f\\n\\r\\t\\003\\177\\234\\313") == 0);
273   TEST (NULL, strcmp(g_strescape("abc\\\"\b\f\n\r\t\003\177\234\313",
274                                  "\b\f\001\002\003\004"),
275                      "abc\\\\\\\"\b\f\\n\\r\\t\003\\177\\234\\313") == 0);
276
277   copy = g_strdupv (vec);
278   TEST (NULL, strcmp (copy[0], "Foo") == 0);
279   TEST (NULL, strcmp (copy[1], "Bar") == 0);
280   TEST (NULL, copy[2] == NULL);
281   g_strfreev (copy);
282   
283   TEST (NULL, strcmp (g_strstr_len ("FooBarFooBarFoo", 6, "Bar"),
284                       "BarFooBarFoo") == 0);
285   TEST (NULL, strcmp (g_strrstr ("FooBarFooBarFoo", "Bar"),
286                       "BarFoo") == 0);
287   TEST (NULL, strcmp (g_strrstr_len ("FooBarFooBarFoo", 14, "BarFoo"),
288                       "BarFooBarFoo") == 0);
289
290   /* Test g_strsplit() */
291   TEST (NULL, strv_check (g_strsplit ("", ",", 0), NULL));
292   TEST (NULL, strv_check (g_strsplit ("x", ",", 0), "x", NULL));
293   TEST (NULL, strv_check (g_strsplit ("x,y", ",", 0), "x", "y", NULL));
294   TEST (NULL, strv_check (g_strsplit ("x,y,", ",", 0), "x", "y", "", NULL));
295   TEST (NULL, strv_check (g_strsplit (",x,y", ",", 0), "", "x", "y", NULL));
296   TEST (NULL, strv_check (g_strsplit (",x,y,", ",", 0), "", "x", "y", "", NULL));
297   TEST (NULL, strv_check (g_strsplit ("x,y,z", ",", 0), "x", "y", "z", NULL));
298   TEST (NULL, strv_check (g_strsplit ("x,y,z,", ",", 0), "x", "y", "z", "", NULL));
299   TEST (NULL, strv_check (g_strsplit (",x,y,z", ",", 0), "", "x", "y", "z", NULL));
300   TEST (NULL, strv_check (g_strsplit (",x,y,z,", ",", 0), "", "x", "y", "z", "", NULL));
301   TEST (NULL, strv_check (g_strsplit (",,x,,y,,z,,", ",", 0), "", "", "x", "", "y", "", "z", "", "", NULL));
302   TEST (NULL, strv_check (g_strsplit (",,x,,y,,z,,", ",,", 0), "", "x", "y", "z", "", NULL));
303
304   TEST (NULL, strv_check (g_strsplit ("", ",", 1), NULL));
305   TEST (NULL, strv_check (g_strsplit ("x", ",", 1), "x", NULL));
306   TEST (NULL, strv_check (g_strsplit ("x,y", ",", 1), "x,y", NULL));
307   TEST (NULL, strv_check (g_strsplit ("x,y,", ",", 1), "x,y,", NULL));
308   TEST (NULL, strv_check (g_strsplit (",x,y", ",", 1), ",x,y", NULL));
309   TEST (NULL, strv_check (g_strsplit (",x,y,", ",", 1), ",x,y,", NULL));
310   TEST (NULL, strv_check (g_strsplit ("x,y,z", ",", 1), "x,y,z", NULL));
311   TEST (NULL, strv_check (g_strsplit ("x,y,z,", ",", 1), "x,y,z,", NULL));
312   TEST (NULL, strv_check (g_strsplit (",x,y,z", ",", 1), ",x,y,z", NULL));
313   TEST (NULL, strv_check (g_strsplit (",x,y,z,", ",", 1), ",x,y,z,", NULL));
314   TEST (NULL, strv_check (g_strsplit (",,x,,y,,z,,", ",", 1), ",,x,,y,,z,,", NULL));
315   TEST (NULL, strv_check (g_strsplit (",,x,,y,,z,,", ",,", 1), ",,x,,y,,z,,", NULL));
316
317   TEST (NULL, strv_check (g_strsplit ("", ",", 2), NULL));
318   TEST (NULL, strv_check (g_strsplit ("x", ",", 2), "x", NULL));
319   TEST (NULL, strv_check (g_strsplit ("x,y", ",", 2), "x", "y", NULL));
320   TEST (NULL, strv_check (g_strsplit ("x,y,", ",", 2), "x", "y,", NULL));
321   TEST (NULL, strv_check (g_strsplit (",x,y", ",", 2), "", "x,y", NULL));
322   TEST (NULL, strv_check (g_strsplit (",x,y,", ",", 2), "", "x,y,", NULL));
323   TEST (NULL, strv_check (g_strsplit ("x,y,z", ",", 2), "x", "y,z", NULL));
324   TEST (NULL, strv_check (g_strsplit ("x,y,z,", ",", 2), "x", "y,z,", NULL));
325   TEST (NULL, strv_check (g_strsplit (",x,y,z", ",", 2), "", "x,y,z", NULL));
326   TEST (NULL, strv_check (g_strsplit (",x,y,z,", ",", 2), "", "x,y,z,", NULL));
327   TEST (NULL, strv_check (g_strsplit (",,x,,y,,z,,", ",", 2), "", ",x,,y,,z,,", NULL));
328   TEST (NULL, strv_check (g_strsplit (",,x,,y,,z,,", ",,", 2), "", "x,,y,,z,,", NULL));
329
330   /* Test g_strsplit_set() */
331   TEST (NULL, strv_check (g_strsplit_set ("", ",/", 0), NULL));
332   TEST (NULL, strv_check (g_strsplit_set (":def/ghi:", ":/", -1), "", "def", "ghi", "", NULL));
333   TEST (NULL, strv_check (g_strsplit_set ("abc:def/ghi", ":/", -1), "abc", "def", "ghi", NULL));
334   TEST (NULL, strv_check (g_strsplit_set (",;,;,;,;", ",;", -1), "", "", "", "", "", "", "", "", "", NULL));
335   TEST (NULL, strv_check (g_strsplit_set (",,abc.def", ".,", -1), "", "", "abc", "def", NULL));
336
337   TEST (NULL, strv_check (g_strsplit_set (",x.y", ",.", 0), "", "x", "y", NULL));
338   TEST (NULL, strv_check (g_strsplit_set (".x,y,", ",.", 0), "", "x", "y", "", NULL));
339   TEST (NULL, strv_check (g_strsplit_set ("x,y.z", ",.", 0), "x", "y", "z", NULL));
340   TEST (NULL, strv_check (g_strsplit_set ("x.y,z,", ",.", 0), "x", "y", "z", "", NULL));
341   TEST (NULL, strv_check (g_strsplit_set (",x.y,z", ",.", 0), "", "x", "y", "z", NULL));
342   TEST (NULL, strv_check (g_strsplit_set (",x,y,z,", ",.", 0), "", "x", "y", "z", "", NULL));
343   TEST (NULL, strv_check (g_strsplit_set (",.x,,y,;z..", ".,;", 0), "", "", "x", "", "y", "", "z", "", "", NULL));
344   TEST (NULL, strv_check (g_strsplit_set (",,x,,y,,z,,", ",,", 0), "", "", "x", "", "y", "", "z", "", "", NULL));
345
346   TEST (NULL, strv_check (g_strsplit_set ("x,y.z", ",.", 1), "x,y.z", NULL));
347   TEST (NULL, strv_check (g_strsplit_set ("x.y,z,", ",.", 1), "x.y,z,", NULL));
348   TEST (NULL, strv_check (g_strsplit_set (",x,y,z", ",.", 1), ",x,y,z", NULL));
349   TEST (NULL, strv_check (g_strsplit_set (",x,y.z,", ",.", 1), ",x,y.z,", NULL));
350   TEST (NULL, strv_check (g_strsplit_set (",,x,.y,,z,,", ",.", 1), ",,x,.y,,z,,", NULL));
351   TEST (NULL, strv_check (g_strsplit_set (",.x,,y,,z,,", ",,..", 1), ",.x,,y,,z,,", NULL));
352    
353   TEST (NULL, strv_check (g_strsplit_set ("", ",", 0), NULL));
354   TEST (NULL, strv_check (g_strsplit_set ("x", ",", 0), "x", NULL));
355   TEST (NULL, strv_check (g_strsplit_set ("x,y", ",", 0), "x", "y", NULL));
356   TEST (NULL, strv_check (g_strsplit_set ("x,y,", ",", 0), "x", "y", "", NULL));
357   TEST (NULL, strv_check (g_strsplit_set (",x,y", ",", 0), "", "x", "y", NULL));
358   TEST (NULL, strv_check (g_strsplit_set (",x,y,", ",", 0), "", "x", "y", "", NULL));
359   TEST (NULL, strv_check (g_strsplit_set ("x,y,z", ",", 0), "x", "y", "z", NULL));
360   TEST (NULL, strv_check (g_strsplit_set ("x,y,z,", ",", 0), "x", "y", "z", "", NULL));
361   TEST (NULL, strv_check (g_strsplit_set (",x,y,z", ",", 0), "", "x", "y", "z", NULL));
362   TEST (NULL, strv_check (g_strsplit_set (",x,y,z,", ",", 0), "", "x", "y", "z", "", NULL));
363   TEST (NULL, strv_check (g_strsplit_set (",,x,,y,,z,,", ",", 0), "", "", "x", "", "y", "", "z", "", "", NULL));
364
365   TEST (NULL, strv_check (g_strsplit_set ("", ",", 1), NULL));
366   TEST (NULL, strv_check (g_strsplit_set ("x", ",", 1), "x", NULL));
367   TEST (NULL, strv_check (g_strsplit_set ("x,y", ",", 1), "x,y", NULL));
368   TEST (NULL, strv_check (g_strsplit_set ("x,y,", ",", 1), "x,y,", NULL));
369   TEST (NULL, strv_check (g_strsplit_set (",x,y", ",", 1), ",x,y", NULL));
370   TEST (NULL, strv_check (g_strsplit_set (",x,y,", ",", 1), ",x,y,", NULL));
371   TEST (NULL, strv_check (g_strsplit_set ("x,y,z", ",", 1), "x,y,z", NULL));
372   TEST (NULL, strv_check (g_strsplit_set ("x,y,z,", ",", 1), "x,y,z,", NULL));
373   TEST (NULL, strv_check (g_strsplit_set (",x,y,z", ",", 1), ",x,y,z", NULL));
374   TEST (NULL, strv_check (g_strsplit_set (",x,y,z,", ",", 1), ",x,y,z,", NULL));
375   TEST (NULL, strv_check (g_strsplit_set (",,x,,y,,z,,", ",", 1), ",,x,,y,,z,,", NULL));
376   TEST (NULL, strv_check (g_strsplit_set (",,x,,y,,z,,", ",,", 1), ",,x,,y,,z,,", NULL));
377
378   TEST (NULL, strv_check (g_strsplit_set ("", ",", 2), NULL));
379   TEST (NULL, strv_check (g_strsplit_set ("x", ",", 2), "x", NULL));
380   TEST (NULL, strv_check (g_strsplit_set ("x,y", ",", 2), "x", "y", NULL));
381   TEST (NULL, strv_check (g_strsplit_set ("x,y,", ",", 2), "x", "y,", NULL));
382   TEST (NULL, strv_check (g_strsplit_set (",x,y", ",", 2), "", "x,y", NULL));
383   TEST (NULL, strv_check (g_strsplit_set (",x,y,", ",", 2), "", "x,y,", NULL));
384   TEST (NULL, strv_check (g_strsplit_set ("x,y,z", ",", 2), "x", "y,z", NULL));
385   TEST (NULL, strv_check (g_strsplit_set ("x,y,z,", ",", 2), "x", "y,z,", NULL));
386   TEST (NULL, strv_check (g_strsplit_set (",x,y,z", ",", 2), "", "x,y,z", NULL));
387   TEST (NULL, strv_check (g_strsplit_set (",x,y,z,", ",", 2), "", "x,y,z,", NULL));
388   TEST (NULL, strv_check (g_strsplit_set (",,x,,y,,z,,", ",", 2), "", ",x,,y,,z,,", NULL));
389   
390   TEST (NULL, strv_check (g_strsplit_set (",,x,.y,..z,,", ",.", 3), "", "", "x,.y,..z,,", NULL));
391
392   
393   
394   #define TEST_IS(name) test_is_function (#name, call_g_ascii_##name, call_##name, g_unichar_##name);
395
396   FOR_ALL_CTYPE(TEST_IS)
397
398   #undef TEST_IS
399
400   #define TEST_TO(name) test_to_function (#name, g_ascii_##name, name, g_unichar_##name)
401
402   TEST_TO (tolower);
403   TEST_TO (toupper);
404
405   #undef TEST_TO
406
407   #define TEST_DIGIT(name) test_digit_function (#name, g_ascii_##name##_value, g_unichar_##name##_value)
408
409   TEST_DIGIT (digit);
410   TEST_DIGIT (xdigit);
411
412   #undef TEST_DIGIT
413
414   /* Tests for strchomp () */
415   TEST (NULL, strchomp_check ("", ""));
416   TEST (NULL, strchomp_check (" ", ""));
417   TEST (NULL, strchomp_check (" \t\r\n", ""));
418   TEST (NULL, strchomp_check ("a ", "a"));
419   TEST (NULL, strchomp_check ("a  ", "a"));
420   TEST (NULL, strchomp_check ("a a", "a a"));
421   TEST (NULL, strchomp_check ("a a ", "a a"));
422
423   /* Tests for g_build_path, g_build_filename */
424
425   TEST (NULL, str_check (g_build_path ("", NULL), ""));
426   TEST (NULL, str_check (g_build_path ("", "", NULL), ""));
427   TEST (NULL, str_check (g_build_path ("", "x", NULL), "x"));
428   TEST (NULL, str_check (g_build_path ("", "x", "y",  NULL), "xy"));
429   TEST (NULL, str_check (g_build_path ("", "x", "y", "z", NULL), "xyz"));
430
431   TEST (NULL, str_check (g_build_path (":", NULL), ""));
432   TEST (NULL, str_check (g_build_path (":", ":", NULL), ":"));
433   TEST (NULL, str_check (g_build_path (":", ":x", NULL), ":x"));
434   TEST (NULL, str_check (g_build_path (":", "x:", NULL), "x:"));
435   TEST (NULL, str_check (g_build_path (":", "", "x", NULL), "x"));
436   TEST (NULL, str_check (g_build_path (":", "", ":x", NULL), ":x"));
437   TEST (NULL, str_check (g_build_path (":", ":", "x", NULL), ":x"));
438   TEST (NULL, str_check (g_build_path (":", "::", "x", NULL), "::x"));
439   TEST (NULL, str_check (g_build_path (":", "x", "", NULL), "x"));
440   TEST (NULL, str_check (g_build_path (":", "x:", "", NULL), "x:"));
441   TEST (NULL, str_check (g_build_path (":", "x", ":", NULL), "x:"));
442   TEST (NULL, str_check (g_build_path (":", "x", "::", NULL), "x::"));
443   TEST (NULL, str_check (g_build_path (":", "x", "y",  NULL), "x:y"));
444   TEST (NULL, str_check (g_build_path (":", ":x", "y", NULL), ":x:y"));
445   TEST (NULL, str_check (g_build_path (":", "x", "y:", NULL), "x:y:"));
446   TEST (NULL, str_check (g_build_path (":", ":x:", ":y:", NULL), ":x:y:"));
447   TEST (NULL, str_check (g_build_path (":", ":x::", "::y:", NULL), ":x:y:"));
448   TEST (NULL, str_check (g_build_path (":", "x", "","y",  NULL), "x:y"));
449   TEST (NULL, str_check (g_build_path (":", "x", ":", "y",  NULL), "x:y"));
450   TEST (NULL, str_check (g_build_path (":", "x", "::", "y",  NULL), "x:y"));
451   TEST (NULL, str_check (g_build_path (":", "x", "y", "z", NULL), "x:y:z"));
452   TEST (NULL, str_check (g_build_path (":", ":x:", ":y:", ":z:", NULL), ":x:y:z:"));
453   TEST (NULL, str_check (g_build_path (":", "::x::", "::y::", "::z::", NULL), "::x:y:z::"));
454
455   TEST (NULL, str_check (g_build_path ("::", NULL), ""));
456   TEST (NULL, str_check (g_build_path ("::", "::", NULL), "::"));
457   TEST (NULL, str_check (g_build_path ("::", ":::", NULL), ":::"));
458   TEST (NULL, str_check (g_build_path ("::", "::x", NULL), "::x"));
459   TEST (NULL, str_check (g_build_path ("::", "x::", NULL), "x::"));
460   TEST (NULL, str_check (g_build_path ("::", "", "x", NULL), "x"));
461   TEST (NULL, str_check (g_build_path ("::", "", "::x", NULL), "::x"));
462   TEST (NULL, str_check (g_build_path ("::", "::", "x", NULL), "::x"));
463   TEST (NULL, str_check (g_build_path ("::", "::::", "x", NULL), "::::x"));
464   TEST (NULL, str_check (g_build_path ("::", "x", "", NULL), "x"));
465   TEST (NULL, str_check (g_build_path ("::", "x::", "", NULL), "x::"));
466   TEST (NULL, str_check (g_build_path ("::", "x", "::", NULL), "x::"));
467   /* This following is weird, but keeps the definition simple */
468   TEST (NULL, str_check (g_build_path ("::", "x", ":::", NULL), "x:::::"));
469   TEST (NULL, str_check (g_build_path ("::", "x", "::::", NULL), "x::::"));
470   TEST (NULL, str_check (g_build_path ("::", "x", "y",  NULL), "x::y"));
471   TEST (NULL, str_check (g_build_path ("::", "::x", "y", NULL), "::x::y"));
472   TEST (NULL, str_check (g_build_path ("::", "x", "y::", NULL), "x::y::"));
473   TEST (NULL, str_check (g_build_path ("::", "::x::", "::y::", NULL), "::x::y::"));
474   TEST (NULL, str_check (g_build_path ("::", "::x:::", ":::y::", NULL), "::x::::y::"));
475   TEST (NULL, str_check (g_build_path ("::", "::x::::", "::::y::", NULL), "::x::y::"));
476   TEST (NULL, str_check (g_build_path ("::", "x", "", "y",  NULL), "x::y"));
477   TEST (NULL, str_check (g_build_path ("::", "x", "::", "y",  NULL), "x::y"));
478   TEST (NULL, str_check (g_build_path ("::", "x", "::::", "y",  NULL), "x::y"));
479   TEST (NULL, str_check (g_build_path ("::", "x", "y", "z", NULL), "x::y::z"));
480   TEST (NULL, str_check (g_build_path ("::", "::x::", "::y::", "::z::", NULL), "::x::y::z::"));
481   TEST (NULL, str_check (g_build_path ("::", ":::x:::", ":::y:::", ":::z:::", NULL), ":::x::::y::::z:::"));
482   TEST (NULL, str_check (g_build_path ("::", "::::x::::", "::::y::::", "::::z::::", NULL), "::::x::y::z::::"));
483
484   args[0] = NULL;
485   TEST (NULL, str_check (g_build_pathv ("", args), ""));
486   args[0] = ""; args[1] = NULL;
487   TEST (NULL, str_check (g_build_pathv ("", args), ""));
488   args[0] = "x"; args[1] = NULL;
489   TEST (NULL, str_check (g_build_pathv ("", args), "x"));
490   args[0] = "x"; args[1] = "y"; args[2] = NULL;
491   TEST (NULL, str_check (g_build_pathv ("", args), "xy"));
492   args[0] = "x"; args[1] = "y"; args[2] = "z", args[3] = NULL;
493   TEST (NULL, str_check (g_build_pathv ("", args), "xyz"));
494
495   args[0] = NULL;
496   TEST (NULL, str_check (g_build_pathv (":", args), ""));
497   args[0] = ":"; args[1] = NULL;
498   TEST (NULL, str_check (g_build_pathv (":", args), ":"));
499   args[0] = ":x"; args[1] = NULL;
500   TEST (NULL, str_check (g_build_pathv (":", args), ":x"));
501   args[0] = "x:"; args[1] = NULL;
502   TEST (NULL, str_check (g_build_pathv (":", args), "x:"));
503   args[0] = ""; args[1] = "x"; args[2] = NULL;
504   TEST (NULL, str_check (g_build_pathv (":", args), "x"));
505   args[0] = ""; args[1] = ":x"; args[2] = NULL;
506   TEST (NULL, str_check (g_build_pathv (":", args), ":x"));
507   args[0] = ":"; args[1] = "x"; args[2] = NULL;
508   TEST (NULL, str_check (g_build_pathv (":", args), ":x"));
509   args[0] = "::"; args[1] = "x"; args[2] = NULL;
510   TEST (NULL, str_check (g_build_pathv (":", args), "::x"));
511   args[0] = "x"; args[1] = ""; args[2] = NULL;
512   TEST (NULL, str_check (g_build_pathv (":", args), "x"));
513   args[0] = "x:"; args[1] = ""; args[2] = NULL;
514   TEST (NULL, str_check (g_build_pathv (":", args), "x:"));
515   args[0] = "x"; args[1] = ":"; args[2] = NULL;
516   TEST (NULL, str_check (g_build_pathv (":", args), "x:"));
517   args[0] = "x"; args[1] = "::"; args[2] = NULL;
518   TEST (NULL, str_check (g_build_pathv (":", args), "x::"));
519   args[0] = "x"; args[1] = "y"; args[2] = NULL;
520   TEST (NULL, str_check (g_build_pathv (":", args), "x:y"));
521   args[0] = ":x"; args[1] = "y"; args[2] = NULL;
522   TEST (NULL, str_check (g_build_pathv (":", args), ":x:y"));
523   args[0] = "x"; args[1] = "y:"; args[2] = NULL;
524   TEST (NULL, str_check (g_build_pathv (":", args), "x:y:"));
525   args[0] = ":x:"; args[1] = ":y:"; args[2] = NULL;
526   TEST (NULL, str_check (g_build_pathv (":", args), ":x:y:"));
527   args[0] = ":x::"; args[1] = "::y:"; args[2] = NULL;
528   TEST (NULL, str_check (g_build_pathv (":", args), ":x:y:"));
529   args[0] = "x"; args[1] = ""; args[2] = "y"; args[3] = NULL;
530   TEST (NULL, str_check (g_build_pathv (":", args), "x:y"));
531   args[0] = "x"; args[1] = ":"; args[2] = "y"; args[3] = NULL;
532   TEST (NULL, str_check (g_build_pathv (":", args), "x:y"));
533   args[0] = "x"; args[1] = "::"; args[2] = "y"; args[3] = NULL;
534   TEST (NULL, str_check (g_build_pathv (":", args), "x:y"));
535   args[0] = "x"; args[1] = "y"; args[2] = "z"; args[3] = NULL;
536   TEST (NULL, str_check (g_build_pathv (":", args), "x:y:z"));
537   args[0] = ":x:"; args[1] = ":y:"; args[2] = ":z:"; args[3] = NULL;
538   TEST (NULL, str_check (g_build_pathv (":", args), ":x:y:z:"));
539   args[0] = "::x::"; args[1] = "::y::"; args[2] = "::z::"; args[3] = NULL;
540   TEST (NULL, str_check (g_build_pathv (":", args), "::x:y:z::"));
541
542   args[0] = NULL;
543   TEST (NULL, str_check (g_build_pathv ("::", args), ""));
544   args[0] = "::"; args[1] = NULL;
545   TEST (NULL, str_check (g_build_pathv ("::", args), "::"));
546   args[0] = ":::"; args[1] = NULL;
547   TEST (NULL, str_check (g_build_pathv ("::", args), ":::"));
548   args[0] = "::x"; args[1] = NULL;
549   TEST (NULL, str_check (g_build_pathv ("::", args), "::x"));
550   args[0] = "x::"; args[1] = NULL;
551   TEST (NULL, str_check (g_build_pathv ("::", args), "x::"));
552   args[0] = ""; args[1] = "x"; args[2] = NULL;
553   TEST (NULL, str_check (g_build_pathv ("::", args), "x"));
554   args[0] = ""; args[1] = "::x"; args[2] = NULL;
555   TEST (NULL, str_check (g_build_pathv ("::", args), "::x"));
556   args[0] = "::"; args[1] = "x"; args[2] = NULL;
557   TEST (NULL, str_check (g_build_pathv ("::", args), "::x"));
558   args[0] = "::::"; args[1] = "x"; args[2] = NULL;
559   TEST (NULL, str_check (g_build_pathv ("::", args), "::::x"));
560   args[0] = "x"; args[1] = ""; args[2] = NULL;
561   TEST (NULL, str_check (g_build_pathv ("::", args), "x"));
562   args[0] = "x::"; args[1] = ""; args[2] = NULL;
563   TEST (NULL, str_check (g_build_pathv ("::", args), "x::"));
564   args[0] = "x"; args[1] = "::"; args[2] = NULL;
565   TEST (NULL, str_check (g_build_pathv ("::", args), "x::"));
566   /* This following is weird, but keeps the definition simple */
567   args[0] = "x"; args[1] = ":::"; args[2] = NULL;
568   TEST (NULL, str_check (g_build_pathv ("::", args), "x:::::"));
569   args[0] = "x"; args[1] = "::::"; args[2] = NULL;
570   TEST (NULL, str_check (g_build_pathv ("::", args), "x::::"));
571   args[0] = "x"; args[1] = "y"; args[2] = NULL;
572   TEST (NULL, str_check (g_build_pathv ("::", args), "x::y"));
573   args[0] = "::x"; args[1] = "y"; args[2] = NULL;
574   TEST (NULL, str_check (g_build_pathv ("::", args), "::x::y"));
575   args[0] = "x"; args[1] = "y::"; args[2] = NULL;
576   TEST (NULL, str_check (g_build_pathv ("::", args), "x::y::"));
577   args[0] = "::x::"; args[1] = "::y::"; args[2] = NULL;
578   TEST (NULL, str_check (g_build_pathv ("::", args), "::x::y::"));
579   args[0] = "::x:::"; args[1] = ":::y::"; args[2] = NULL;
580   TEST (NULL, str_check (g_build_pathv ("::", args), "::x::::y::"));
581   args[0] = "::x::::"; args[1] = "::::y::"; args[2] = NULL;
582   TEST (NULL, str_check (g_build_pathv ("::", args), "::x::y::"));
583   args[0] = "x"; args[1] = ""; args[2] = "y"; args[3] = NULL;
584   TEST (NULL, str_check (g_build_pathv ("::", args), "x::y"));
585   args[0] = "x"; args[1] = "::"; args[2] = "y"; args[3] = NULL;
586   TEST (NULL, str_check (g_build_pathv ("::", args), "x::y"));
587   args[0] = "x"; args[1] = "::::"; args[2] = "y"; args[3] = NULL;
588   TEST (NULL, str_check (g_build_pathv ("::", args), "x::y"));
589   args[0] = "x"; args[1] = "y"; args[2] = "z"; args[3] = NULL;
590   TEST (NULL, str_check (g_build_pathv ("::", args), "x::y::z"));
591   args[0] = "::x::"; args[1] = "::y::"; args[2] = "::z::"; args[3] = NULL;
592   TEST (NULL, str_check (g_build_pathv ("::", args), "::x::y::z::"));
593   args[0] = ":::x:::"; args[1] = ":::y:::"; args[2] = ":::z:::"; args[3] = NULL;
594   TEST (NULL, str_check (g_build_pathv ("::", args), ":::x::::y::::z:::"));
595   args[0] = "::::x::::"; args[1] = "::::y::::"; args[2] = "::::z::::"; args[3] = NULL;
596   TEST (NULL, str_check (g_build_pathv ("::", args), "::::x::y::z::::"));
597
598 #define S G_DIR_SEPARATOR_S
599
600   TEST (NULL, str_check (g_build_filename (NULL), ""));
601   TEST (NULL, str_check (g_build_filename (S, NULL), S));
602   TEST (NULL, str_check (g_build_filename (S"x", NULL), S"x"));
603   TEST (NULL, str_check (g_build_filename ("x"S, NULL), "x"S));
604   TEST (NULL, str_check (g_build_filename ("", "x", NULL), "x"));
605   TEST (NULL, str_check (g_build_filename ("", S"x", NULL), S"x"));
606   TEST (NULL, str_check (g_build_filename (S, "x", NULL), S"x"));
607   TEST (NULL, str_check (g_build_filename (S S, "x", NULL), S S"x"));
608   TEST (NULL, str_check (g_build_filename ("x", "", NULL), "x"));
609   TEST (NULL, str_check (g_build_filename ("x"S, "", NULL), "x"S));
610   TEST (NULL, str_check (g_build_filename ("x", S, NULL), "x"S));
611   TEST (NULL, str_check (g_build_filename ("x", S S, NULL), "x"S S));
612   TEST (NULL, str_check (g_build_filename ("x", "y",  NULL), "x"S"y"));
613   TEST (NULL, str_check (g_build_filename (S"x", "y", NULL), S"x"S"y"));
614   TEST (NULL, str_check (g_build_filename ("x", "y"S, NULL), "x"S"y"S));
615   TEST (NULL, str_check (g_build_filename (S"x"S, S"y"S, NULL), S"x"S"y"S));
616   TEST (NULL, str_check (g_build_filename (S"x"S S, S S"y"S, NULL), S"x"S"y"S));
617   TEST (NULL, str_check (g_build_filename ("x", "", "y",  NULL), "x"S"y"));
618   TEST (NULL, str_check (g_build_filename ("x", S, "y",  NULL), "x"S"y"));
619   TEST (NULL, str_check (g_build_filename ("x", S S, "y",  NULL), "x"S"y"));
620   TEST (NULL, str_check (g_build_filename ("x", "y", "z", NULL), "x"S"y"S"z"));
621   TEST (NULL, str_check (g_build_filename (S"x"S, S"y"S, S"z"S, NULL), S"x"S"y"S"z"S));
622   TEST (NULL, str_check (g_build_filename (S S"x"S S, S S"y"S S, S S"z"S S, NULL), S S"x"S"y"S"z"S S));
623
624   args[0] = NULL;
625   TEST (NULL, str_check (g_build_filenamev (args), ""));
626   args[0] = S; args[1] = NULL;
627   TEST (NULL, str_check (g_build_filenamev (args), S));
628   args[0] = S"x"; args[1] = NULL;
629   TEST (NULL, str_check (g_build_filenamev (args), S"x"));
630   args[0] = "x"S; args[1] = NULL;
631   TEST (NULL, str_check (g_build_filenamev (args), "x"S));
632   args[0] = ""; args[1] = "x"; args[2] = NULL;
633   TEST (NULL, str_check (g_build_filenamev (args), "x"));
634   args[0] = ""; args[1] = S"x"; args[2] = NULL;
635   TEST (NULL, str_check (g_build_filenamev (args), S"x"));
636   args[0] = S; args[1] = "x"; args[2] = NULL;
637   TEST (NULL, str_check (g_build_filenamev (args), S"x"));
638   args[0] = S S; args[1] = "x"; args[2] = NULL;
639   TEST (NULL, str_check (g_build_filenamev (args), S S"x"));
640   args[0] = "x"; args[1] = ""; args[2] = NULL;
641   TEST (NULL, str_check (g_build_filenamev (args), "x"));
642   args[0] = "x"S; args[1] = ""; args[2] = NULL;
643   TEST (NULL, str_check (g_build_filenamev (args), "x"S));
644   args[0] = "x"; args[1] = S; args[2] = NULL;
645   TEST (NULL, str_check (g_build_filenamev (args), "x"S));
646   args[0] = "x"; args[1] = S S; args[2] = NULL;
647   TEST (NULL, str_check (g_build_filenamev (args), "x"S S));
648   args[0] = "x"; args[1] = "y"; args[2] = NULL;
649   TEST (NULL, str_check (g_build_filenamev (args), "x"S"y"));
650   args[0] = S"x"; args[1] = "y"; args[2] = NULL;
651   TEST (NULL, str_check (g_build_filenamev (args), S"x"S"y"));
652   args[0] = "x"; args[1] = "y"S; args[2] = NULL;
653   TEST (NULL, str_check (g_build_filenamev (args), "x"S"y"S));
654   args[0] = S"x"S; args[1] = S"y"S; args[2] = NULL;
655   TEST (NULL, str_check (g_build_filenamev (args), S"x"S"y"S));
656   args[0] = S"x"S S; args[1] = S S"y"S; args[2] = NULL;
657   TEST (NULL, str_check (g_build_filenamev (args), S"x"S"y"S));
658   args[0] = "x"; args[1] = ""; args[2] = "y"; args[3] = NULL;
659   TEST (NULL, str_check (g_build_filenamev (args), "x"S"y"));
660   args[0] = "x"; args[1] = S; args[2] = "y"; args[3] = NULL;
661   TEST (NULL, str_check (g_build_filenamev (args), "x"S"y"));
662   args[0] = "x"; args[1] = S S; args[2] = "y"; args[3] = NULL;
663   TEST (NULL, str_check (g_build_filenamev (args), "x"S"y"));
664   args[0] = "x"; args[1] = "y"; args[2] = "z"; args[3] = NULL;
665   TEST (NULL, str_check (g_build_filenamev (args), "x"S"y"S"z"));
666   args[0] = S"x"S; args[1] = S"y"S; args[2] = S"z"S; args[3] = NULL;
667   TEST (NULL, str_check (g_build_filenamev (args), S"x"S"y"S"z"S));
668   args[0] = S S"x"S S; args[1] = S S"y"S S; args[2] = S S"z"S S; args[3] = NULL;
669   TEST (NULL, str_check (g_build_filenamev (args), S S"x"S"y"S"z"S S));
670
671 #ifdef G_OS_WIN32
672
673   /* Test also using the slash as file name separator */
674 #define U "/"
675   TEST (NULL, str_check (g_build_filename (NULL), ""));
676   TEST (NULL, str_check (g_build_filename (U, NULL), U));
677   TEST (NULL, str_check (g_build_filename (U"x", NULL), U"x"));
678   TEST (NULL, str_check (g_build_filename ("x"U, NULL), "x"U));
679   TEST (NULL, str_check (g_build_filename ("", U"x", NULL), U"x"));
680   TEST (NULL, str_check (g_build_filename ("", U"x", NULL), U"x"));
681   TEST (NULL, str_check (g_build_filename (U, "x", NULL), U"x"));
682   TEST (NULL, str_check (g_build_filename (U U, "x", NULL), U U"x"));
683   TEST (NULL, str_check (g_build_filename (U S, "x", NULL), U S"x"));
684   TEST (NULL, str_check (g_build_filename ("x"U, "", NULL), "x"U));
685   TEST (NULL, str_check (g_build_filename ("x"S"y", "z"U"a", NULL), "x"S"y"S"z"U"a"));
686   TEST (NULL, str_check (g_build_filename ("x", U, NULL), "x"U));
687   TEST (NULL, str_check (g_build_filename ("x", U U, NULL), "x"U U));
688   TEST (NULL, str_check (g_build_filename ("x", S U, NULL), "x"S U));
689   TEST (NULL, str_check (g_build_filename (U"x", "y", NULL), U"x"U"y"));
690   TEST (NULL, str_check (g_build_filename ("x", "y"U, NULL), "x"U"y"U));
691   TEST (NULL, str_check (g_build_filename (U"x"U, U"y"U, NULL), U"x"U"y"U));
692   TEST (NULL, str_check (g_build_filename (U"x"U U, U U"y"U, NULL), U"x"U"y"U));
693   TEST (NULL, str_check (g_build_filename ("x", U, "y",  NULL), "x"U"y"));
694   TEST (NULL, str_check (g_build_filename ("x", U U, "y",  NULL), "x"U"y"));
695   TEST (NULL, str_check (g_build_filename ("x", U S, "y",  NULL), "x"S"y"));
696   TEST (NULL, str_check (g_build_filename ("x", S U, "y",  NULL), "x"U"y"));
697   TEST (NULL, str_check (g_build_filename ("x", U "y", "z", NULL), "x"U"y"U"z"));
698   TEST (NULL, str_check (g_build_filename ("x", S "y", "z", NULL), "x"S"y"S"z"));
699   TEST (NULL, str_check (g_build_filename ("x", S "y", "z", U, "a", "b", NULL), "x"S"y"S"z"U"a"U"b"));
700   TEST (NULL, str_check (g_build_filename (U"x"U, U"y"U, U"z"U, NULL), U"x"U"y"U"z"U));
701   TEST (NULL, str_check (g_build_filename (U U"x"U U, U U"y"U U, U U"z"U U, NULL), U U"x"U"y"U"z"U U));
702
703   args[0] = NULL;
704   TEST (NULL, str_check (g_build_filenamev (args), ""));
705   args[0] = U; args[1] = NULL;
706   TEST (NULL, str_check (g_build_filenamev (args), U));
707   args[0] = U"x"; args[1] = NULL;
708   TEST (NULL, str_check (g_build_filenamev (args), U"x"));
709   args[0] = "x"U; args[1] = NULL;
710   TEST (NULL, str_check (g_build_filenamev (args), "x"U));
711   args[0] = ""; args[1] = U"x"; args[2] = NULL;
712   TEST (NULL, str_check (g_build_filenamev (args), U"x"));
713   args[0] = ""; args[1] = U"x"; args[2] = NULL;
714   TEST (NULL, str_check (g_build_filenamev (args), U"x"));
715   args[0] = U; args[1] = "x"; args[2] = NULL;
716   TEST (NULL, str_check (g_build_filenamev (args), U"x"));
717   args[0] = U U; args[1] = "x"; args[2] = NULL;
718   TEST (NULL, str_check (g_build_filenamev (args), U U"x"));
719   args[0] = U S; args[1] = "x"; args[2] = NULL;
720   TEST (NULL, str_check (g_build_filenamev (args), U S"x"));
721   args[0] = "x"U; args[1] = ""; args[2] = NULL;
722   TEST (NULL, str_check (g_build_filenamev (args), "x"U));
723   args[0] = "x"S"y"; args[1] = "z"U"a"; args[2] = NULL;
724   TEST (NULL, str_check (g_build_filenamev (args), "x"S"y"S"z"U"a"));
725   args[0] = "x"; args[1] = U; args[2] = NULL;
726   TEST (NULL, str_check (g_build_filenamev (args), "x"U));
727   args[0] = "x"; args[1] = U U; args[2] = NULL;
728   TEST (NULL, str_check (g_build_filenamev (args), "x"U U));
729   args[0] = "x"; args[1] = S U; args[2] = NULL;
730   TEST (NULL, str_check (g_build_filenamev (args), "x"S U));
731   args[0] = U"x"; args[1] = "y"; args[2] = NULL;
732   TEST (NULL, str_check (g_build_filenamev (args), U"x"U"y"));
733   args[0] = "x"; args[1] = "y"U; args[2] = NULL;
734   TEST (NULL, str_check (g_build_filenamev (args), "x"U"y"U));
735   args[0] = U"x"U; args[1] = U"y"U; args[2] = NULL;
736   TEST (NULL, str_check (g_build_filenamev (args), U"x"U"y"U));
737   args[0] = U"x"U U; args[1] = U U"y"U; args[2] = NULL;
738   TEST (NULL, str_check (g_build_filenamev (args), U"x"U"y"U));
739   args[0] = "x"; args[1] = U; args[2] = "y", args[3] = NULL;
740   TEST (NULL, str_check (g_build_filenamev (args), "x"U"y"));
741   args[0] = "x"; args[1] = U U; args[2] = "y", args[3] = NULL;
742   TEST (NULL, str_check (g_build_filenamev (args), "x"U"y"));
743   args[0] = "x"; args[1] = U S; args[2] = "y", args[3] = NULL;
744   TEST (NULL, str_check (g_build_filenamev (args), "x"S"y"));
745   args[0] = "x"; args[1] = S U; args[2] = "y", args[3] = NULL;
746   TEST (NULL, str_check (g_build_filenamev (args), "x"U"y"));
747   args[0] = "x"; args[1] = U "y"; args[2] = "z", args[3] = NULL;
748   TEST (NULL, str_check (g_build_filenamev (args), "x"U"y"U"z"));
749   args[0] = "x"; args[1] = S "y"; args[2] = "z", args[3] = NULL;
750   TEST (NULL, str_check (g_build_filenamev (args), "x"S"y"S"z"));
751   args[0] = "x"; args[1] = S "y"; args[2] = "z", args[3] = U;
752   args[4] = "a"; args[5] = "b"; args[6] = NULL;
753   TEST (NULL, str_check (g_build_filenamev (args), "x"S"y"S"z"U"a"U"b"));
754   args[0] = U"x"U; args[1] = U"y"U; args[2] = U"z"U, args[3] = NULL;
755   TEST (NULL, str_check (g_build_filenamev (args), U"x"U"y"U"z"U));
756   args[0] = U U"x"U U; args[1] = U U"y"U U; args[2] = U U"z"U U, args[3] = NULL;
757   TEST (NULL, str_check (g_build_filenamev (args), U U"x"U"y"U"z"U U));
758 #endif /* G_OS_WIN32 */
759
760 #undef S
761
762   {
763     gchar buf[5];
764     
765     TEST (NULL, 3 == g_snprintf (buf, 0, "%s", "abc"));
766     TEST (NULL, 3 == g_snprintf (NULL,0, "%s", "abc"));
767     TEST (NULL, 3 == g_snprintf (buf, 5, "%s", "abc"));
768     TEST (NULL, 4 == g_snprintf (buf, 5, "%s", "abcd"));
769     TEST (NULL, 9 == g_snprintf (buf, 5, "%s", "abcdefghi"));
770   }
771
772   TEST (NULL, g_strv_length (g_strsplit ("1,2,3,4", ",", -1)) == 4);
773
774   return any_failed;
775 }