source: trunk/third/glib2/tests/strfunc-test.c @ 18159

Revision 18159, 17.8 KB checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18158, which included commits to RCS files with non-trunk default branches.
Line 
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
36static gboolean any_failed = FALSE;
37static gboolean failed = FALSE;
38
39#define TEST(m,cond)    G_STMT_START { failed = !(cond); \
40if (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
55static gboolean
56strv_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
84static gboolean
85str_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
95static gboolean
96strchomp_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
136FOR_ALL_CTYPE (DEFINE_CALL_CTYPE)
137FOR_ALL_CTYPE (DEFINE_CALL_G_ASCII_CTYPE)
138
139static void
140test_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
168static void
169test_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
197static void
198test_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
221int
222main (int   argc,
223      char *argv[])
224{
225  gchar *string;
226  gchar *vec[] = { "Foo", "Bar", NULL };
227  gchar **copy;
228 
229  TEST (NULL, g_ascii_strcasecmp ("FroboZZ", "frobozz") == 0);
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", "froboz") != 0);
233  TEST (NULL, g_ascii_strcasecmp ("", "") == 0);
234  TEST (NULL, g_ascii_strcasecmp ("!#%&/()", "!#%&/()") == 0);
235  TEST (NULL, g_ascii_strcasecmp ("a", "b") < 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 ("b", "a") > 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
244  TEST (NULL, g_strdup (NULL) == NULL);
245  string = g_strdup (GLIB_TEST_STRING);
246  TEST (NULL, string != NULL);
247  TEST (NULL, strcmp (string, GLIB_TEST_STRING) == 0);
248  g_free(string);
249 
250  string = g_strconcat (GLIB_TEST_STRING, NULL);
251  TEST (NULL, string != NULL);
252  TEST (NULL, strcmp (string, GLIB_TEST_STRING) == 0);
253  g_free(string);
254 
255  string = g_strconcat (GLIB_TEST_STRING, GLIB_TEST_STRING,
256                        GLIB_TEST_STRING, NULL);
257  TEST (NULL, string != NULL);
258  TEST (NULL, strcmp (string, GLIB_TEST_STRING GLIB_TEST_STRING
259                      GLIB_TEST_STRING) == 0);
260  g_free(string);
261 
262  string = g_strdup_printf ("%05d %-5s", 21, "test");
263  TEST (NULL, string != NULL);
264  TEST (NULL, strcmp(string, "00021 test ") == 0);
265  g_free (string);
266 
267  TEST (NULL, strcmp
268        (g_strcompress ("abc\\\\\\\"\\b\\f\\n\\r\\t\\003\\177\\234\\313\\12345z"),
269         "abc\\\"\b\f\n\r\t\003\177\234\313\12345z") == 0);
270  TEST (NULL, strcmp (g_strescape("abc\\\"\b\f\n\r\t\003\177\234\313", NULL),
271                      "abc\\\\\\\"\\b\\f\\n\\r\\t\\003\\177\\234\\313") == 0);
272  TEST (NULL, strcmp(g_strescape("abc\\\"\b\f\n\r\t\003\177\234\313",
273                                 "\b\f\001\002\003\004"),
274                     "abc\\\\\\\"\b\f\\n\\r\\t\003\\177\\234\\313") == 0);
275
276  copy = g_strdupv (vec);
277  TEST (NULL, strcmp (copy[0], "Foo") == 0);
278  TEST (NULL, strcmp (copy[1], "Bar") == 0);
279  TEST (NULL, copy[2] == NULL);
280  g_strfreev (copy);
281 
282  TEST (NULL, strcmp (g_strstr_len ("FooBarFooBarFoo", 6, "Bar"),
283                      "BarFooBarFoo") == 0);
284  TEST (NULL, strcmp (g_strrstr ("FooBarFooBarFoo", "Bar"),
285                      "BarFoo") == 0);
286  TEST (NULL, strcmp (g_strrstr_len ("FooBarFooBarFoo", 14, "BarFoo"),
287                      "BarFooBarFoo") == 0);
288
289  TEST (NULL, strv_check (g_strsplit ("", ",", 0), NULL));
290  TEST (NULL, strv_check (g_strsplit ("x", ",", 0), "x", NULL));
291  TEST (NULL, strv_check (g_strsplit ("x,y", ",", 0), "x", "y", NULL));
292  TEST (NULL, strv_check (g_strsplit ("x,y,", ",", 0), "x", "y", "", 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,z", ",", 0), "x", "y", "z", NULL));
296  TEST (NULL, strv_check (g_strsplit ("x,y,z,", ",", 0), "x", "y", "z", "", 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
302  TEST (NULL, strv_check (g_strsplit ("", ",", 1), NULL));
303  TEST (NULL, strv_check (g_strsplit ("x", ",", 1), "x", NULL));
304  TEST (NULL, strv_check (g_strsplit ("x,y", ",", 1), "x,y", NULL));
305  TEST (NULL, strv_check (g_strsplit ("x,y,", ",", 1), "x,y,", 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,z", ",", 1), "x,y,z", NULL));
309  TEST (NULL, strv_check (g_strsplit ("x,y,z,", ",", 1), "x,y,z,", 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
315  TEST (NULL, strv_check (g_strsplit ("", ",", 2), NULL));
316  TEST (NULL, strv_check (g_strsplit ("x", ",", 2), "x", NULL));
317  TEST (NULL, strv_check (g_strsplit ("x,y", ",", 2), "x", "y", NULL));
318  TEST (NULL, strv_check (g_strsplit ("x,y,", ",", 2), "x", "y,", 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,z", ",", 2), "x", "y,z", NULL));
322  TEST (NULL, strv_check (g_strsplit ("x,y,z,", ",", 2), "x", "y,z,", 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
328  #define TEST_IS(name) test_is_function (#name, call_g_ascii_##name, call_##name, g_unichar_##name);
329
330  FOR_ALL_CTYPE(TEST_IS)
331
332  #undef TEST_IS
333
334  #define TEST_TO(name) test_to_function (#name, g_ascii_##name, name, g_unichar_##name)
335
336  TEST_TO (tolower);
337  TEST_TO (toupper);
338
339  #undef TEST_TO
340
341  #define TEST_DIGIT(name) test_digit_function (#name, g_ascii_##name##_value, g_unichar_##name##_value)
342
343  TEST_DIGIT (digit);
344  TEST_DIGIT (xdigit);
345
346  #undef TEST_DIGIT
347
348  /* Tests for strchomp () */
349  TEST (NULL, strchomp_check ("", ""));
350  TEST (NULL, strchomp_check (" ", ""));
351  TEST (NULL, strchomp_check (" \t\r\n", ""));
352  TEST (NULL, strchomp_check ("a ", "a"));
353  TEST (NULL, strchomp_check ("a  ", "a"));
354  TEST (NULL, strchomp_check ("a a", "a a"));
355  TEST (NULL, strchomp_check ("a a ", "a a"));
356
357  /* Tests for g_build_path, g_build_filename */
358
359  TEST (NULL, str_check (g_build_path ("", NULL), ""));
360  TEST (NULL, str_check (g_build_path ("", "", NULL), ""));
361  TEST (NULL, str_check (g_build_path ("", "x", NULL), "x"));
362  TEST (NULL, str_check (g_build_path ("", "x", "y",  NULL), "xy"));
363  TEST (NULL, str_check (g_build_path ("", "x", "y", "z", NULL), "xyz"));
364
365  TEST (NULL, str_check (g_build_path (":", NULL), ""));
366  TEST (NULL, str_check (g_build_path (":", ":", NULL), ":"));
367  TEST (NULL, str_check (g_build_path (":", ":x", NULL), ":x"));
368  TEST (NULL, str_check (g_build_path (":", "x:", NULL), "x:"));
369  TEST (NULL, str_check (g_build_path (":", "", "x", NULL), "x"));
370  TEST (NULL, str_check (g_build_path (":", "", ":x", NULL), ":x"));
371  TEST (NULL, str_check (g_build_path (":", ":", "x", NULL), ":x"));
372  TEST (NULL, str_check (g_build_path (":", "::", "x", NULL), "::x"));
373  TEST (NULL, str_check (g_build_path (":", "x", "", NULL), "x"));
374  TEST (NULL, str_check (g_build_path (":", "x:", "", NULL), "x:"));
375  TEST (NULL, str_check (g_build_path (":", "x", ":", NULL), "x:"));
376  TEST (NULL, str_check (g_build_path (":", "x", "::", NULL), "x::"));
377  TEST (NULL, str_check (g_build_path (":", "x", "y",  NULL), "x:y"));
378  TEST (NULL, str_check (g_build_path (":", ":x", "y", NULL), ":x:y"));
379  TEST (NULL, str_check (g_build_path (":", "x", "y:", NULL), "x:y:"));
380  TEST (NULL, str_check (g_build_path (":", ":x:", ":y:", NULL), ":x:y:"));
381  TEST (NULL, str_check (g_build_path (":", ":x::", "::y:", NULL), ":x:y:"));
382  TEST (NULL, str_check (g_build_path (":", "x", "","y",  NULL), "x:y"));
383  TEST (NULL, str_check (g_build_path (":", "x", ":", "y",  NULL), "x:y"));
384  TEST (NULL, str_check (g_build_path (":", "x", "::", "y",  NULL), "x:y"));
385  TEST (NULL, str_check (g_build_path (":", "x", "y", "z", NULL), "x:y:z"));
386  TEST (NULL, str_check (g_build_path (":", ":x:", ":y:", ":z:", NULL), ":x:y:z:"));
387  TEST (NULL, str_check (g_build_path (":", "::x::", "::y::", "::z::", NULL), "::x:y:z::"));
388
389  TEST (NULL, str_check (g_build_path ("::", NULL), ""));
390  TEST (NULL, str_check (g_build_path ("::", "::", NULL), "::"));
391  TEST (NULL, str_check (g_build_path ("::", ":::", NULL), ":::"));
392  TEST (NULL, str_check (g_build_path ("::", "::x", NULL), "::x"));
393  TEST (NULL, str_check (g_build_path ("::", "x::", NULL), "x::"));
394  TEST (NULL, str_check (g_build_path ("::", "", "x", NULL), "x"));
395  TEST (NULL, str_check (g_build_path ("::", "", "::x", NULL), "::x"));
396  TEST (NULL, str_check (g_build_path ("::", "::", "x", NULL), "::x"));
397  TEST (NULL, str_check (g_build_path ("::", "::::", "x", NULL), "::::x"));
398  TEST (NULL, str_check (g_build_path ("::", "x", "", NULL), "x"));
399  TEST (NULL, str_check (g_build_path ("::", "x::", "", NULL), "x::"));
400  TEST (NULL, str_check (g_build_path ("::", "x", "::", NULL), "x::"));
401  /* This following is weird, but keeps the definition simple */
402  TEST (NULL, str_check (g_build_path ("::", "x", ":::", NULL), "x:::::"));
403  TEST (NULL, str_check (g_build_path ("::", "x", "::::", NULL), "x::::"));
404  TEST (NULL, str_check (g_build_path ("::", "x", "y",  NULL), "x::y"));
405  TEST (NULL, str_check (g_build_path ("::", "::x", "y", NULL), "::x::y"));
406  TEST (NULL, str_check (g_build_path ("::", "x", "y::", NULL), "x::y::"));
407  TEST (NULL, str_check (g_build_path ("::", "::x::", "::y::", NULL), "::x::y::"));
408  TEST (NULL, str_check (g_build_path ("::", "::x:::", ":::y::", NULL), "::x::::y::"));
409  TEST (NULL, str_check (g_build_path ("::", "::x::::", "::::y::", NULL), "::x::y::"));
410  TEST (NULL, str_check (g_build_path ("::", "x", "", "y",  NULL), "x::y"));
411  TEST (NULL, str_check (g_build_path ("::", "x", "::", "y",  NULL), "x::y"));
412  TEST (NULL, str_check (g_build_path ("::", "x", "::::", "y",  NULL), "x::y"));
413  TEST (NULL, str_check (g_build_path ("::", "x", "y", "z", NULL), "x::y::z"));
414  TEST (NULL, str_check (g_build_path ("::", "::x::", "::y::", "::z::", NULL), "::x::y::z::"));
415  TEST (NULL, str_check (g_build_path ("::", ":::x:::", ":::y:::", ":::z:::", NULL), ":::x::::y::::z:::"));
416  TEST (NULL, str_check (g_build_path ("::", "::::x::::", "::::y::::", "::::z::::", NULL), "::::x::y::z::::"));
417
418#define S G_DIR_SEPARATOR_S
419
420  TEST (NULL, str_check (g_build_filename (NULL), ""));
421  TEST (NULL, str_check (g_build_filename (S, NULL), S));
422  TEST (NULL, str_check (g_build_filename (S"x", NULL), S"x"));
423  TEST (NULL, str_check (g_build_filename ("x"S, NULL), "x"S));
424  TEST (NULL, str_check (g_build_filename ("", "x", NULL), "x"));
425  TEST (NULL, str_check (g_build_filename ("", S"x", NULL), S"x"));
426  TEST (NULL, str_check (g_build_filename (S, "x", NULL), S"x"));
427  TEST (NULL, str_check (g_build_filename (S S, "x", NULL), S S"x"));
428  TEST (NULL, str_check (g_build_filename ("x", "", NULL), "x"));
429  TEST (NULL, str_check (g_build_filename ("x"S, "", NULL), "x"S));
430  TEST (NULL, str_check (g_build_filename ("x", S, NULL), "x"S));
431  TEST (NULL, str_check (g_build_filename ("x", S S, NULL), "x"S S));
432  TEST (NULL, str_check (g_build_filename ("x", "y",  NULL), "x"S"y"));
433  TEST (NULL, str_check (g_build_filename (S"x", "y", NULL), S"x"S"y"));
434  TEST (NULL, str_check (g_build_filename ("x", "y"S, NULL), "x"S"y"S));
435  TEST (NULL, str_check (g_build_filename (S"x"S, S"y"S, NULL), S"x"S"y"S));
436  TEST (NULL, str_check (g_build_filename (S"x"S S, S S"y"S, NULL), S"x"S"y"S));
437  TEST (NULL, str_check (g_build_filename ("x", "", "y",  NULL), "x"S"y"));
438  TEST (NULL, str_check (g_build_filename ("x", S, "y",  NULL), "x"S"y"));
439  TEST (NULL, str_check (g_build_filename ("x", S S, "y",  NULL), "x"S"y"));
440  TEST (NULL, str_check (g_build_filename ("x", "y", "z", NULL), "x"S"y"S"z"));
441  TEST (NULL, str_check (g_build_filename (S"x"S, S"y"S, S"z"S, NULL), S"x"S"y"S"z"S));
442  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));
443
444#undef S
445
446  {
447    gchar buf[5];
448   
449    TEST (NULL, 3 == g_snprintf (buf, 0, "%s", "abc"));
450    TEST (NULL, 3 == g_snprintf (NULL,0, "%s", "abc"));
451    TEST (NULL, 3 == g_snprintf (buf, 5, "%s", "abc"));
452    TEST (NULL, 4 == g_snprintf (buf, 5, "%s", "abcd"));
453    TEST (NULL, 9 == g_snprintf (buf, 5, "%s", "abcdefghi"));
454  }
455
456  return any_failed;
457}
Note: See TracBrowser for help on using the repository browser.