Bug 556186 – gpoll.h breaks gmain.h inclusion
[platform/upstream/glib.git] / glib / tests / strfuncs.c
1 /* Unit tests for gstrfuncs
2  * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * This work is provided "as is"; redistribution and modification
5  * in whole or in part, in any medium, physical or electronic is
6  * permitted without restriction.
7  *
8  * This work is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  *
12  * In no event shall the authors or contributors be liable for any
13  * direct, indirect, incidental, special, exemplary, or consequential
14  * damages (including, but not limited to, procurement of substitute
15  * goods or services; loss of use, data, or profits; or business
16  * interruption) however caused and on any theory of liability, whether
17  * in contract, strict liability, or tort (including negligence or
18  * otherwise) arising in any way out of the use of this software, even
19  * if advised of the possibility of such damage.
20  */
21
22 #include <ctype.h>
23 #include <errno.h>
24 #include <locale.h>
25 #include <math.h>
26 #include <stdarg.h>
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include "glib.h"
31
32 #define GLIB_TEST_STRING "el dorado "
33
34 #define FOR_ALL_CTYPE(macro)    \
35         macro(isalnum)          \
36         macro(isalpha)          \
37         macro(iscntrl)          \
38         macro(isdigit)          \
39         macro(isgraph)          \
40         macro(islower)          \
41         macro(isprint)          \
42         macro(ispunct)          \
43         macro(isspace)          \
44         macro(isupper)          \
45         macro(isxdigit)
46
47 #define DEFINE_CALL_CTYPE(function)             \
48         static int                              \
49         call_##function (int c)                 \
50         {                                       \
51                 return function (c);            \
52         }
53
54 #define DEFINE_CALL_G_ASCII_CTYPE(function)     \
55         static gboolean                         \
56         call_g_ascii_##function (gchar c)       \
57         {                                       \
58                 return g_ascii_##function (c);  \
59         }
60
61 FOR_ALL_CTYPE (DEFINE_CALL_CTYPE)
62 FOR_ALL_CTYPE (DEFINE_CALL_G_ASCII_CTYPE)
63
64 static void
65 test_is_function (const char *name,
66                   gboolean (* ascii_function) (gchar),
67                   int (* c_library_function) (int),
68                   gboolean (* unicode_function) (gunichar))
69 {
70   int c;
71
72   for (c = 0; c <= 0x7F; c++)
73     {
74       gboolean ascii_result = ascii_function ((gchar)c);
75       gboolean c_library_result = c_library_function (c) != 0;
76       gboolean unicode_result = unicode_function ((gunichar) c);
77       if (ascii_result != c_library_result && c != '\v')
78         {
79           g_error ("g_ascii_%s returned %d and %s returned %d for 0x%X",
80                    name, ascii_result, name, c_library_result, c);
81         }
82       if (ascii_result != unicode_result)
83         {
84           g_error ("g_ascii_%s returned %d and g_unichar_%s returned %d for 0x%X",
85                    name, ascii_result, name, unicode_result, c);
86         }
87     }
88   for (c = 0x80; c <= 0xFF; c++)
89     {
90       gboolean ascii_result = ascii_function ((gchar)c);
91       if (ascii_result)
92         {
93           g_error ("g_ascii_%s returned TRUE for 0x%X", name, c);
94         }
95     }
96 }
97
98 static void
99 test_to_function (const char *name,
100                   gchar (* ascii_function) (gchar),
101                   int (* c_library_function) (int),
102                   gunichar (* unicode_function) (gunichar))
103 {
104   int c;
105
106   for (c = 0; c <= 0x7F; c++)
107     {
108       int ascii_result = (guchar) ascii_function ((gchar) c);
109       int c_library_result = c_library_function (c);
110       int unicode_result = unicode_function ((gunichar) c);
111       if (ascii_result != c_library_result)
112         {
113           g_error ("g_ascii_%s returned 0x%X and %s returned 0x%X for 0x%X",
114                    name, ascii_result, name, c_library_result, c);
115         }
116       if (ascii_result != unicode_result)
117         {
118           g_error ("g_ascii_%s returned 0x%X and g_unichar_%s returned 0x%X for 0x%X",
119                    name, ascii_result, name, unicode_result, c);
120         }
121     }
122   for (c = 0x80; c <= 0xFF; c++)
123     {
124       int ascii_result = (guchar) ascii_function ((gchar) c);
125       if (ascii_result != c)
126         {
127           g_error ("g_ascii_%s returned 0x%X for 0x%X",
128                    name, ascii_result, c);
129         }
130     }
131 }
132
133 static void
134 test_digit_function (const char *name,
135                      int (* ascii_function) (gchar),
136                      int (* unicode_function) (gunichar))
137 {
138   int c;
139
140   for (c = 0; c <= 0x7F; c++)
141     {
142       int ascii_result = ascii_function ((gchar) c);
143       int unicode_result = unicode_function ((gunichar) c);
144       if (ascii_result != unicode_result)
145         {
146           g_error ("g_ascii_%s_value returned %d and g_unichar_%s_value returned %d for 0x%X",
147                    name, ascii_result, name, unicode_result, c);
148         }
149     }
150   for (c = 0x80; c <= 0xFF; c++)
151     {
152       int ascii_result = ascii_function ((gchar) c);
153       if (ascii_result != -1)
154         {
155           g_error ("g_ascii_%s_value returned %d for 0x%X",
156                    name, ascii_result, c);
157         }
158     }
159 }
160
161 static void
162 test_is_to_digit (void)
163 {
164   #define TEST_IS(name) test_is_function (#name, call_g_ascii_##name, call_##name, g_unichar_##name);
165
166   FOR_ALL_CTYPE(TEST_IS)
167
168   #undef TEST_IS
169
170   #define TEST_TO(name) test_to_function (#name, g_ascii_##name, name, g_unichar_##name)
171
172   TEST_TO (tolower);
173   TEST_TO (toupper);
174
175   #undef TEST_TO
176
177   #define TEST_DIGIT(name) test_digit_function (#name, g_ascii_##name##_value, g_unichar_##name##_value)
178
179   TEST_DIGIT (digit);
180   TEST_DIGIT (xdigit);
181
182   #undef TEST_DIGIT
183 }
184
185 static void
186 test_strdup (void)
187 {
188   gchar *str;
189
190   str = g_strdup (NULL);
191   g_assert (str == NULL);
192
193   str = g_strdup (GLIB_TEST_STRING);
194   g_assert (str != NULL);
195   g_assert_cmpstr (str, ==, GLIB_TEST_STRING);
196   g_free (str);
197 }
198
199 static void
200 test_strndup (void)
201 {
202   gchar *str;
203
204   str = g_strndup (NULL, 3);
205   g_assert (str == NULL);
206
207   str = g_strndup ("aaaa", 5);
208   g_assert (str != NULL);
209   g_assert_cmpstr (str, ==, "aaaa");
210   g_free (str);
211
212   str = g_strndup ("aaaa", 2);
213   g_assert (str != NULL);
214   g_assert_cmpstr (str, ==, "aa");
215   g_free (str);
216 }
217
218 static void
219 test_strdup_printf (void)
220 {
221   gchar *str;
222
223   str = g_strdup_printf ("%05d %-5s", 21, "test");
224   g_assert (str != NULL);
225   g_assert_cmpstr (str, ==, "00021 test ");
226   g_free (str);
227 }
228
229 static void
230 test_strdupv (void)
231 {
232   gchar *vec[] = { "Foo", "Bar", NULL };
233   gchar **copy;
234
235   copy = g_strdupv (NULL);
236   g_assert (copy == NULL);  
237
238   copy = g_strdupv (vec);
239   g_assert (copy != NULL);
240   g_assert_cmpstr (copy[0], ==, "Foo");
241   g_assert_cmpstr (copy[1], ==, "Bar");
242   g_assert (copy[2] == NULL);
243   g_strfreev (copy);
244 }
245
246 static void
247 test_strnfill (void)
248 {
249   gchar *str;
250
251   str = g_strnfill (0, 'a');
252   g_assert (str != NULL);
253   g_assert (*str == '\0');
254   g_free (str);
255
256   str = g_strnfill (5, 'a');
257   g_assert (str != NULL);
258   g_assert_cmpstr (str, ==, "aaaaa");
259   g_free (str);
260 }
261
262 static void
263 test_strconcat (void)
264 {
265   gchar *str;
266
267   str = g_strconcat (GLIB_TEST_STRING, NULL);
268   g_assert (str != NULL);
269   g_assert_cmpstr (str, ==, GLIB_TEST_STRING);
270   g_free (str);
271
272   str = g_strconcat (GLIB_TEST_STRING,
273                      GLIB_TEST_STRING, 
274                      GLIB_TEST_STRING,
275                      NULL);
276   g_assert (str != NULL);
277   g_assert_cmpstr (str, ==, GLIB_TEST_STRING GLIB_TEST_STRING GLIB_TEST_STRING);
278   g_free (str);
279 }
280
281 static void
282 test_strjoin (void)
283 {
284   gchar *str;
285
286   str = g_strjoin (NULL, NULL);
287   g_assert (str != NULL);
288   g_assert (*str == '\0');
289   g_free (str);
290
291   str = g_strjoin (":", NULL);
292   g_assert (str != NULL);
293   g_assert (*str == '\0');
294   g_free (str);
295
296   str = g_strjoin (NULL, GLIB_TEST_STRING, NULL);
297   g_assert (str != NULL);
298   g_assert_cmpstr (str, ==, GLIB_TEST_STRING);
299   g_free (str);
300
301   str = g_strjoin (NULL,
302                    GLIB_TEST_STRING,
303                    GLIB_TEST_STRING, 
304                    GLIB_TEST_STRING,
305                    NULL);
306   g_assert (str != NULL);
307   g_assert_cmpstr (str, ==, GLIB_TEST_STRING GLIB_TEST_STRING GLIB_TEST_STRING);
308   g_free (str);
309
310   str = g_strjoin (":",
311                    GLIB_TEST_STRING,
312                    GLIB_TEST_STRING, 
313                    GLIB_TEST_STRING,
314                    NULL);
315   g_assert (str != NULL);
316   g_assert_cmpstr (str, ==, GLIB_TEST_STRING ":" GLIB_TEST_STRING ":" GLIB_TEST_STRING);
317   g_free (str);
318 }
319
320 static void
321 test_strcanon (void)
322 {
323   gchar *str;
324
325   if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
326     {
327       str = g_strcanon (NULL, "ab", 'y');
328     }
329   g_test_trap_assert_failed ();
330
331   if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
332     {
333       str = g_strdup ("abxabxab");
334       str = g_strcanon (str, NULL, 'y');
335       g_free (str);
336     }
337   g_test_trap_assert_failed ();
338
339   str = g_strdup ("abxabxab");
340   str = g_strcanon (str, "ab", 'y');
341   g_assert (str != NULL);
342   g_assert_cmpstr (str, ==, "abyabyab");
343   g_free (str);
344 }
345
346 static void
347 test_strcompress_strescape (void)
348 {
349   gchar *str;
350   gchar *tmp;
351
352   /* test compress */
353   if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
354     {
355       str = g_strcompress (NULL);
356     }
357   g_test_trap_assert_failed ();
358
359   /* trailing slashes are not allowed */
360   if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
361     {
362       str = g_strcompress ("abc\\");
363     }
364   g_test_trap_assert_failed ();
365
366   str = g_strcompress ("abc\\\\\\\"\\b\\f\\n\\r\\t\\003\\177\\234\\313\\12345z");
367   g_assert (str != NULL);
368   g_assert_cmpstr (str, ==, "abc\\\"\b\f\n\r\t\003\177\234\313\12345z");
369   g_free (str);
370
371   /* test escape */
372   if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
373     {
374       str = g_strescape (NULL, NULL);
375     }
376   g_test_trap_assert_failed ();
377
378   str = g_strescape ("abc\\\"\b\f\n\r\t\003\177\234\313", NULL);
379   g_assert (str != NULL);
380   g_assert_cmpstr (str, ==, "abc\\\\\\\"\\b\\f\\n\\r\\t\\003\\177\\234\\313");
381   g_free (str);
382
383   str = g_strescape ("abc\\\"\b\f\n\r\t\003\177\234\313",
384                      "\b\f\001\002\003\004");
385   g_assert (str != NULL);
386   g_assert_cmpstr (str, ==, "abc\\\\\\\"\b\f\\n\\r\\t\003\\177\\234\\313");
387   g_free (str);
388
389   /* round trip */
390   tmp = g_strescape ("abc\\\"\b\f\n\r\t\003\177\234\313", NULL);
391   str = g_strcompress (tmp);
392   g_assert (str != NULL); 
393   g_assert_cmpstr (str, ==, "abc\\\"\b\f\n\r\t\003\177\234\313");
394   g_free (str);
395   g_free (tmp);
396 }
397
398 static void
399 test_ascii_strcasecmp (void)
400 {
401   gboolean res;
402
403   if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
404     {
405       res = g_ascii_strcasecmp ("foo", NULL);
406     }
407   g_test_trap_assert_failed ();
408
409   if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
410     {
411       res = g_ascii_strcasecmp (NULL, "foo");
412     }
413   g_test_trap_assert_failed ();
414
415   res = g_ascii_strcasecmp ("FroboZZ", "frobozz");
416   g_assert_cmpint (res, ==, 0);
417
418   res = g_ascii_strcasecmp ("frobozz", "frobozz");
419   g_assert_cmpint (res, ==, 0);
420
421   res = g_ascii_strcasecmp ("frobozz", "FROBOZZ");
422   g_assert_cmpint (res, ==, 0);
423
424   res = g_ascii_strcasecmp ("FROBOZZ", "froboz");
425   g_assert_cmpint (res, !=, 0);
426
427   res = g_ascii_strcasecmp ("", "");
428   g_assert_cmpint (res, ==, 0);
429
430   res = g_ascii_strcasecmp ("!#%&/()", "!#%&/()");
431   g_assert_cmpint (res, ==, 0);
432
433   res = g_ascii_strcasecmp ("a", "b");
434   g_assert_cmpint (res, <, 0);
435
436   res = g_ascii_strcasecmp ("a", "B");
437   g_assert_cmpint (res, <, 0);
438
439   res = g_ascii_strcasecmp ("A", "b");
440   g_assert_cmpint (res, <, 0);
441
442   res = g_ascii_strcasecmp ("A", "B");
443   g_assert_cmpint (res, <, 0);
444
445   res = g_ascii_strcasecmp ("b", "a");
446   g_assert_cmpint (res, >, 0);
447
448   res = g_ascii_strcasecmp ("b", "A");
449   g_assert_cmpint (res, >, 0);
450
451   res = g_ascii_strcasecmp ("B", "a");
452   g_assert_cmpint (res, >, 0);
453
454   res = g_ascii_strcasecmp ("B", "A");
455   g_assert_cmpint (res, >, 0);
456 }
457
458 static void
459 do_test_strchug (const gchar *str, const gchar *expected)
460 {
461   gchar *tmp;
462   gboolean res;
463
464   tmp = g_strdup (str);
465
466   g_strchug (tmp);
467   res = (strcmp (tmp, expected) == 0);
468   g_free (tmp);
469
470   g_assert_cmpint (res, ==, TRUE);
471 }
472
473 static void
474 test_strchug (void)
475 {
476   if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
477     {
478       g_strchug (NULL);
479     }
480   g_test_trap_assert_failed ();
481
482   do_test_strchug ("", "");
483   do_test_strchug (" ", "");
484   do_test_strchug ("\t\r\n ", "");
485   do_test_strchug (" a", "a");
486   do_test_strchug ("  a", "a");
487   do_test_strchug ("a a", "a a");
488   do_test_strchug (" a a", "a a");
489 }
490
491 static void
492 do_test_strchomp (const gchar *str, const gchar *expected)
493 {
494   gchar *tmp;
495   gboolean res;
496
497   tmp = g_strdup (str);
498
499   g_strchomp (tmp);
500   res = (strcmp (tmp, expected) == 0);
501   g_free (tmp);
502
503   g_assert_cmpint (res, ==, TRUE);
504 }
505
506 static void
507 test_strchomp (void)
508 {
509   if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
510     {
511       g_strchomp (NULL);
512     }
513   g_test_trap_assert_failed ();
514
515   do_test_strchomp ("", "");
516   do_test_strchomp (" ", "");
517   do_test_strchomp (" \t\r\n", "");
518   do_test_strchomp ("a ", "a");
519   do_test_strchomp ("a  ", "a");
520   do_test_strchomp ("a a", "a a");
521   do_test_strchomp ("a a ", "a a");
522 }
523
524 static void
525 test_strreverse (void)
526 {
527   gchar *str;
528   gchar *p;
529
530   if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
531     {
532       str = g_strreverse (NULL);
533     }
534   g_test_trap_assert_failed ();
535
536   str = p = g_strdup ("abcde");
537   str = g_strreverse (str);
538   g_assert (str != NULL);
539   g_assert (p == str);
540   g_assert_cmpstr (str, ==, "edcba");
541   g_free (str);
542 }
543
544 static void
545 test_strstr (void)
546 {
547   gchar *haystack;
548   gchar *res;
549
550   haystack = g_strdup ("FooBarFooBarFoo");
551
552   /* strstr_len */
553   res = g_strstr_len (haystack, 6, "xxx");
554   g_assert (res == NULL);
555
556   res = g_strstr_len (haystack, 6, "FooBarFooBarFooBar");
557   g_assert (res == NULL);
558
559   res = g_strstr_len (haystack, 3, "Bar");
560   g_assert (res == NULL);
561
562   res = g_strstr_len (haystack, 6, "");
563   g_assert (res == haystack);
564   g_assert_cmpstr (res, ==, "FooBarFooBarFoo");
565
566   res = g_strstr_len (haystack, 6, "Bar");
567   g_assert (res == haystack + 3);
568   g_assert_cmpstr (res, ==, "BarFooBarFoo");
569
570   res = g_strstr_len (haystack, -1, "Bar");
571   g_assert (res == haystack + 3);
572   g_assert_cmpstr (res, ==, "BarFooBarFoo");
573
574   /* strrstr */
575   res = g_strrstr (haystack, "xxx");
576   g_assert (res == NULL);
577
578   res = g_strrstr (haystack, "FooBarFooBarFooBar");
579   g_assert (res == NULL);
580
581   res = g_strrstr (haystack, "");
582   g_assert (res == haystack);
583   g_assert_cmpstr (res, ==, "FooBarFooBarFoo");
584
585   res = g_strrstr (haystack, "Bar");
586   g_assert (res == haystack + 9);
587   g_assert_cmpstr (res, ==, "BarFoo");
588
589   /* strrstr_len */
590   res = g_strrstr_len (haystack, 14, "xxx");
591   g_assert (res == NULL);
592
593   res = g_strrstr_len (haystack, 14, "FooBarFooBarFooBar");
594   g_assert (res == NULL);
595
596   res = g_strrstr_len (haystack, 3, "Bar");
597   g_assert (res == NULL);
598
599   res = g_strrstr_len (haystack, 14, "BarFoo");
600   g_assert (res == haystack + 3);
601   g_assert_cmpstr (res, ==, "BarFooBarFoo");
602
603   res = g_strrstr_len (haystack, 15, "BarFoo");
604   g_assert (res == haystack + 9);
605   g_assert_cmpstr (res, ==, "BarFoo");
606
607   res = g_strrstr_len (haystack, -1, "BarFoo");
608   g_assert (res == haystack + 9);
609   g_assert_cmpstr (res, ==, "BarFoo");
610
611   /* test case for strings with \0 in the middle */
612   *(haystack + 7) = '\0';
613   res = g_strstr_len (haystack, 15, "BarFoo");
614   g_assert (res == NULL);
615
616   g_free (haystack);
617 }
618
619 static void
620 test_has_prefix (void)
621 {
622   gboolean res;
623
624   if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
625     {
626       res = g_str_has_prefix ("foo", NULL);
627     }
628   g_test_trap_assert_failed ();
629
630   if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
631     {
632       res = g_str_has_prefix (NULL, "foo");
633     }
634   g_test_trap_assert_failed ();
635
636   res = g_str_has_prefix ("foo", "bar");
637   g_assert_cmpint (res, ==, FALSE);
638
639   res = g_str_has_prefix ("foo", "foobar");
640   g_assert_cmpint (res, ==, FALSE);
641
642   res = g_str_has_prefix ("foobar", "bar");
643   g_assert_cmpint (res, ==, FALSE);
644
645   res = g_str_has_prefix ("foobar", "foo");
646   g_assert_cmpint (res, ==, TRUE);
647
648   res = g_str_has_prefix ("foo", "");
649   g_assert_cmpint (res, ==, TRUE);
650
651   res = g_str_has_prefix ("foo", "foo");
652   g_assert_cmpint (res, ==, TRUE);
653
654   res = g_str_has_prefix ("", "");
655   g_assert_cmpint (res, ==, TRUE);
656 }
657
658 static void
659 test_has_suffix (void)
660 {
661   gboolean res;
662
663   if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
664     {
665       res = g_str_has_suffix ("foo", NULL);
666     }
667   g_test_trap_assert_failed ();
668
669   if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
670     {
671       res = g_str_has_suffix (NULL, "foo");
672     }
673   g_test_trap_assert_failed ();
674
675   res = g_str_has_suffix ("foo", "bar");
676   g_assert_cmpint (res, ==, FALSE);
677
678   res = g_str_has_suffix ("bar", "foobar");
679   g_assert_cmpint (res, ==, FALSE);
680
681   res = g_str_has_suffix ("foobar", "foo");
682   g_assert_cmpint (res, ==, FALSE);
683
684   res = g_str_has_suffix ("foobar", "bar");
685   g_assert_cmpint (res, ==, TRUE);
686
687   res = g_str_has_suffix ("foo", "");
688   g_assert_cmpint (res, ==, TRUE);
689
690   res = g_str_has_suffix ("foo", "foo");
691   g_assert_cmpint (res, ==, TRUE);
692
693   res = g_str_has_suffix ("", "");
694   g_assert_cmpint (res, ==, TRUE);
695 }
696
697 static void
698 strv_check (gchar **strv, ...)
699 {
700   gboolean ok = TRUE;
701   gint i = 0;
702   va_list list;
703
704   va_start (list, strv);
705   while (ok)
706     {
707       const gchar *str = va_arg (list, const char *);
708       if (strv[i] == NULL)
709         {
710           g_assert (str == NULL);
711           break;
712         }
713       if (str == NULL)
714         {
715           ok = FALSE;
716         }
717       else
718         {
719           g_assert_cmpstr (strv[i], ==, str);
720         }
721       i++;
722     }
723   va_end (list);
724
725   g_strfreev (strv);
726 }
727
728 static void
729 test_strsplit (void)
730 {
731   strv_check (g_strsplit ("", ",", 0), NULL);
732   strv_check (g_strsplit ("x", ",", 0), "x", NULL);
733   strv_check (g_strsplit ("x,y", ",", 0), "x", "y", NULL);
734   strv_check (g_strsplit ("x,y,", ",", 0), "x", "y", "", NULL);
735   strv_check (g_strsplit (",x,y", ",", 0), "", "x", "y", NULL);
736   strv_check (g_strsplit (",x,y,", ",", 0), "", "x", "y", "", NULL);
737   strv_check (g_strsplit ("x,y,z", ",", 0), "x", "y", "z", NULL);
738   strv_check (g_strsplit ("x,y,z,", ",", 0), "x", "y", "z", "", NULL);
739   strv_check (g_strsplit (",x,y,z", ",", 0), "", "x", "y", "z", NULL);
740   strv_check (g_strsplit (",x,y,z,", ",", 0), "", "x", "y", "z", "", NULL);
741   strv_check (g_strsplit (",,x,,y,,z,,", ",", 0), "", "", "x", "", "y", "", "z", "", "", NULL);
742   strv_check (g_strsplit (",,x,,y,,z,,", ",,", 0), "", "x", "y", "z", "", NULL);
743
744   strv_check (g_strsplit ("", ",", 1), NULL);
745   strv_check (g_strsplit ("x", ",", 1), "x", NULL);
746   strv_check (g_strsplit ("x,y", ",", 1), "x,y", NULL);
747   strv_check (g_strsplit ("x,y,", ",", 1), "x,y,", NULL);
748   strv_check (g_strsplit (",x,y", ",", 1), ",x,y", NULL);
749   strv_check (g_strsplit (",x,y,", ",", 1), ",x,y,", NULL);
750   strv_check (g_strsplit ("x,y,z", ",", 1), "x,y,z", NULL);
751   strv_check (g_strsplit ("x,y,z,", ",", 1), "x,y,z,", NULL);
752   strv_check (g_strsplit (",x,y,z", ",", 1), ",x,y,z", NULL);
753   strv_check (g_strsplit (",x,y,z,", ",", 1), ",x,y,z,", NULL);
754   strv_check (g_strsplit (",,x,,y,,z,,", ",", 1), ",,x,,y,,z,,", NULL);
755   strv_check (g_strsplit (",,x,,y,,z,,", ",,", 1), ",,x,,y,,z,,", NULL);
756
757   strv_check (g_strsplit ("", ",", 2), NULL);
758   strv_check (g_strsplit ("x", ",", 2), "x", NULL);
759   strv_check (g_strsplit ("x,y", ",", 2), "x", "y", NULL);
760   strv_check (g_strsplit ("x,y,", ",", 2), "x", "y,", NULL);
761   strv_check (g_strsplit (",x,y", ",", 2), "", "x,y", NULL);
762   strv_check (g_strsplit (",x,y,", ",", 2), "", "x,y,", NULL);
763   strv_check (g_strsplit ("x,y,z", ",", 2), "x", "y,z", NULL);
764   strv_check (g_strsplit ("x,y,z,", ",", 2), "x", "y,z,", NULL);
765   strv_check (g_strsplit (",x,y,z", ",", 2), "", "x,y,z", NULL);
766   strv_check (g_strsplit (",x,y,z,", ",", 2), "", "x,y,z,", NULL);
767   strv_check (g_strsplit (",,x,,y,,z,,", ",", 2), "", ",x,,y,,z,,", NULL);
768   strv_check (g_strsplit (",,x,,y,,z,,", ",,", 2), "", "x,,y,,z,,", NULL);
769 }
770
771 static void
772 test_strsplit_set (void)
773 {
774   strv_check (g_strsplit_set ("", ",/", 0), NULL);
775   strv_check (g_strsplit_set (":def/ghi:", ":/", -1), "", "def", "ghi", "", NULL);
776   strv_check (g_strsplit_set ("abc:def/ghi", ":/", -1), "abc", "def", "ghi", NULL);
777   strv_check (g_strsplit_set (",;,;,;,;", ",;", -1), "", "", "", "", "", "", "", "", "", NULL);
778   strv_check (g_strsplit_set (",,abc.def", ".,", -1), "", "", "abc", "def", NULL);
779
780   strv_check (g_strsplit_set (",x.y", ",.", 0), "", "x", "y", NULL);
781   strv_check (g_strsplit_set (".x,y,", ",.", 0), "", "x", "y", "", NULL);
782   strv_check (g_strsplit_set ("x,y.z", ",.", 0), "x", "y", "z", NULL);
783   strv_check (g_strsplit_set ("x.y,z,", ",.", 0), "x", "y", "z", "", NULL);
784   strv_check (g_strsplit_set (",x.y,z", ",.", 0), "", "x", "y", "z", NULL);
785   strv_check (g_strsplit_set (",x,y,z,", ",.", 0), "", "x", "y", "z", "", NULL);
786   strv_check (g_strsplit_set (",.x,,y,;z..", ".,;", 0), "", "", "x", "", "y", "", "z", "", "", NULL);
787   strv_check (g_strsplit_set (",,x,,y,,z,,", ",,", 0), "", "", "x", "", "y", "", "z", "", "", NULL);
788
789   strv_check (g_strsplit_set ("x,y.z", ",.", 1), "x,y.z", NULL);
790   strv_check (g_strsplit_set ("x.y,z,", ",.", 1), "x.y,z,", NULL);
791   strv_check (g_strsplit_set (",x,y,z", ",.", 1), ",x,y,z", NULL);
792   strv_check (g_strsplit_set (",x,y.z,", ",.", 1), ",x,y.z,", NULL);
793   strv_check (g_strsplit_set (",,x,.y,,z,,", ",.", 1), ",,x,.y,,z,,", NULL);
794   strv_check (g_strsplit_set (",.x,,y,,z,,", ",,..", 1), ",.x,,y,,z,,", NULL);
795    
796   strv_check (g_strsplit_set ("", ",", 0), NULL);
797   strv_check (g_strsplit_set ("x", ",", 0), "x", NULL);
798   strv_check (g_strsplit_set ("x,y", ",", 0), "x", "y", NULL);
799   strv_check (g_strsplit_set ("x,y,", ",", 0), "x", "y", "", NULL);
800   strv_check (g_strsplit_set (",x,y", ",", 0), "", "x", "y", NULL);
801   strv_check (g_strsplit_set (",x,y,", ",", 0), "", "x", "y", "", NULL);
802   strv_check (g_strsplit_set ("x,y,z", ",", 0), "x", "y", "z", NULL);
803   strv_check (g_strsplit_set ("x,y,z,", ",", 0), "x", "y", "z", "", NULL);
804   strv_check (g_strsplit_set (",x,y,z", ",", 0), "", "x", "y", "z", NULL);
805   strv_check (g_strsplit_set (",x,y,z,", ",", 0), "", "x", "y", "z", "", NULL);
806   strv_check (g_strsplit_set (",,x,,y,,z,,", ",", 0), "", "", "x", "", "y", "", "z", "", "", NULL);
807
808   strv_check (g_strsplit_set ("", ",", 1), NULL);
809   strv_check (g_strsplit_set ("x", ",", 1), "x", NULL);
810   strv_check (g_strsplit_set ("x,y", ",", 1), "x,y", NULL);
811   strv_check (g_strsplit_set ("x,y,", ",", 1), "x,y,", NULL);
812   strv_check (g_strsplit_set (",x,y", ",", 1), ",x,y", NULL);
813   strv_check (g_strsplit_set (",x,y,", ",", 1), ",x,y,", NULL);
814   strv_check (g_strsplit_set ("x,y,z", ",", 1), "x,y,z", NULL);
815   strv_check (g_strsplit_set ("x,y,z,", ",", 1), "x,y,z,", NULL);
816   strv_check (g_strsplit_set (",x,y,z", ",", 1), ",x,y,z", NULL);
817   strv_check (g_strsplit_set (",x,y,z,", ",", 1), ",x,y,z,", NULL);
818   strv_check (g_strsplit_set (",,x,,y,,z,,", ",", 1), ",,x,,y,,z,,", NULL);
819   strv_check (g_strsplit_set (",,x,,y,,z,,", ",,", 1), ",,x,,y,,z,,", NULL);
820
821   strv_check (g_strsplit_set ("", ",", 2), NULL);
822   strv_check (g_strsplit_set ("x", ",", 2), "x", NULL);
823   strv_check (g_strsplit_set ("x,y", ",", 2), "x", "y", NULL);
824   strv_check (g_strsplit_set ("x,y,", ",", 2), "x", "y,", NULL);
825   strv_check (g_strsplit_set (",x,y", ",", 2), "", "x,y", NULL);
826   strv_check (g_strsplit_set (",x,y,", ",", 2), "", "x,y,", NULL);
827   strv_check (g_strsplit_set ("x,y,z", ",", 2), "x", "y,z", NULL);
828   strv_check (g_strsplit_set ("x,y,z,", ",", 2), "x", "y,z,", NULL);
829   strv_check (g_strsplit_set (",x,y,z", ",", 2), "", "x,y,z", NULL);
830   strv_check (g_strsplit_set (",x,y,z,", ",", 2), "", "x,y,z,", NULL);
831   strv_check (g_strsplit_set (",,x,,y,,z,,", ",", 2), "", ",x,,y,,z,,", NULL);
832   
833   strv_check (g_strsplit_set (",,x,.y,..z,,", ",.", 3), "", "", "x,.y,..z,,", NULL);
834 }
835
836 static void
837 test_strv_length (void)
838 {
839   guint l;
840
841   if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
842     {
843       l = g_strv_length (NULL);
844     }
845   g_test_trap_assert_failed ();
846
847   l = g_strv_length (g_strsplit ("1,2,3,4", ",", -1));
848   g_assert_cmpuint (l, ==, 4);
849 }
850
851 static char *locales[] = {"sv_SE", "en_US", "fa_IR", "C", "ru_RU"};
852
853 void
854 check_strtod_string (gchar    *number,
855                      double    res,
856                      gboolean  check_end,
857                      gint      correct_len)
858 {
859   double d;
860   gint l;
861   gchar *dummy;
862
863   /* we try a copy of number, with some free space for malloc before that. 
864    * This is supposed to smash the some wrong pointer calculations. */
865
866   dummy = g_malloc (100000);
867   number = g_strdup (number);
868   g_free (dummy);
869
870   for (l = 0; l < G_N_ELEMENTS (locales); l++)
871     {
872       gboolean ok;
873       gchar *end = "(unset)";
874
875       setlocale (LC_NUMERIC, locales[l]);
876       d = g_ascii_strtod (number, &end);
877       ok = isnan (res) ? isnan (d) : (d == res);
878       if (!ok)
879         {
880           g_error ("g_ascii_strtod on \"%s\" for locale %s failed\n" \
881                    "expected %f (nan %d) actual %f (nan %d)\n", 
882                    number, locales[l],
883                    res, isnan (res),
884                    d, isnan (d));
885         }
886
887       ok = (end - number) == (check_end ? correct_len : strlen (number));
888       if (!ok) {
889         if (end == NULL)
890           g_error ("g_ascii_strtod on \"%s\" for locale %s endptr was NULL\n",
891                    number, locales[l]);
892         else if (end >= number && end <= number + strlen (number))
893           g_error ("g_ascii_strtod on \"%s\" for locale %s endptr was wrong, leftover: \"%s\"\n",
894                    number, locales[l], end);
895         else
896           g_error ("g_ascii_strtod on \"%s\" for locale %s endptr was REALLY wrong (number=%p, end=%p)\n",
897                    number, locales[l], number, end);
898       }
899     }
900
901   g_free (number);
902 }
903
904 static void
905 check_strtod_number (gdouble num, gchar *fmt, gchar *str)
906 {
907   int l;
908   gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
909
910   for (l = 0; l < G_N_ELEMENTS (locales); l++)
911     {
912       g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, fmt, num);
913       g_assert_cmpstr (buf, ==, str);
914     }
915 }
916
917 static void
918 test_strtod (void)
919 {
920   gdouble d, our_nan, our_inf;
921   char buffer[G_ASCII_DTOSTR_BUF_SIZE];
922
923 #ifdef NAN
924   our_nan = NAN;
925 #else
926   /* Do this before any call to setlocale.  */
927   our_nan = atof ("NaN");
928 #endif
929   g_assert (isnan (our_nan));
930
931 #ifdef INFINITY
932   our_inf = INFINITY;
933 #else
934   our_inf = atof ("Infinity");
935 #endif
936   g_assert (our_inf > 1 && our_inf == our_inf / 2);
937
938   check_strtod_string ("123.123", 123.123, FALSE, 0);
939   check_strtod_string ("123.123e2", 123.123e2, FALSE, 0);
940   check_strtod_string ("123.123e-2", 123.123e-2, FALSE, 0);
941   check_strtod_string ("-123.123", -123.123, FALSE, 0);
942   check_strtod_string ("-123.123e2", -123.123e2, FALSE, 0);
943   check_strtod_string ("-123.123e-2", -123.123e-2, FALSE, 0);
944   check_strtod_string ("5.4", 5.4, TRUE, 3);
945   check_strtod_string ("5.4,5.5", 5.4, TRUE, 3);
946   check_strtod_string ("5,4", 5.0, TRUE, 1);
947   /* the following are for #156421 */
948   check_strtod_string ("1e1", 1e1, FALSE, 0); 
949   check_strtod_string ("NAN", our_nan, FALSE, 0);
950   check_strtod_string ("-nan", -our_nan, FALSE, 0);
951   check_strtod_string ("INF", our_inf, FALSE, 0);
952   check_strtod_string ("-infinity", -our_inf, FALSE, 0);
953   check_strtod_string ("-.75,0", -0.75, TRUE, 4);
954   
955   d = 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0;
956   g_assert (d == g_ascii_strtod (g_ascii_dtostr (buffer, sizeof (buffer), d), NULL));
957
958   d = -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0;
959   g_assert (d == g_ascii_strtod (g_ascii_dtostr (buffer, sizeof (buffer), d), NULL));
960   
961   d = pow (2.0, -1024.1);
962   g_assert (d == g_ascii_strtod (g_ascii_dtostr (buffer, sizeof (buffer), d), NULL));
963   
964   d = -pow (2.0, -1024.1);
965   g_assert (d == g_ascii_strtod (g_ascii_dtostr (buffer, sizeof (buffer), d), NULL));
966
967   /* for #343899 */
968   check_strtod_string (" 0.75", 0.75, FALSE, 0);
969   check_strtod_string (" +0.75", 0.75, FALSE, 0);
970   check_strtod_string (" -0.75", -0.75, FALSE, 0);
971   check_strtod_string ("\f0.75", 0.75, FALSE, 0);
972   check_strtod_string ("\n0.75", 0.75, FALSE, 0);
973   check_strtod_string ("\r0.75", 0.75, FALSE, 0);
974   check_strtod_string ("\t0.75", 0.75, FALSE, 0);
975
976 #if 0
977   /* g_ascii_isspace() returns FALSE for vertical tab, see #59388 */
978   check_strtod_string ("\v0.75", 0.75, FALSE, 0);
979 #endif
980
981   /* for #343899 */
982   check_strtod_number (0.75, "%0.2f", "0.75");
983   check_strtod_number (0.75, "%5.2f", " 0.75");
984   check_strtod_number (-0.75, "%0.2f", "-0.75");
985   check_strtod_number (-0.75, "%5.2f", "-0.75");
986   check_strtod_number (1e99, "%.0e", "1e+99");
987 }
988
989 static void
990 check_uint64 (const gchar *str,
991               const gchar *end,
992               gint         base,
993               guint64      result,
994               gint         error)
995 {
996   guint64 actual;
997   gchar *endptr = NULL;
998   gint err;
999
1000   errno = 0;
1001   actual = g_ascii_strtoull (str, &endptr, base);
1002   err = errno;
1003
1004   g_assert (actual == result);
1005   g_assert_cmpstr (end, ==, endptr);
1006   g_assert (err == error);
1007 }
1008
1009 static void
1010 check_int64 (const gchar *str,
1011              const gchar *end,
1012              gint         base,
1013              gint64       result,
1014              gint         error)
1015 {
1016   gint64 actual;
1017   gchar *endptr = NULL;
1018   gint err;
1019
1020   errno = 0;
1021   actual = g_ascii_strtoll (str, &endptr, base);
1022   err = errno;
1023
1024   g_assert (actual == result);
1025   g_assert_cmpstr (end, ==, endptr);
1026   g_assert (err == error);
1027 }
1028
1029 static void
1030 test_strtoll (void)
1031 {
1032   check_uint64 ("0", "", 10, 0, 0);
1033   check_uint64 ("+0", "", 10, 0, 0);
1034   check_uint64 ("-0", "", 10, 0, 0);
1035   check_uint64 ("18446744073709551615", "", 10, G_MAXUINT64, 0);
1036   check_uint64 ("18446744073709551616", "", 10, G_MAXUINT64, ERANGE);
1037   check_uint64 ("20xyz", "xyz", 10, 20, 0);
1038   check_uint64 ("-1", "", 10, G_MAXUINT64, 0);
1039
1040   check_int64 ("0", "", 10, 0, 0);
1041   check_int64 ("9223372036854775807", "", 10, G_MAXINT64, 0);
1042   check_int64 ("9223372036854775808", "", 10, G_MAXINT64, ERANGE);
1043   check_int64 ("-9223372036854775808", "", 10, G_MININT64, 0);
1044   check_int64 ("-9223372036854775809", "", 10, G_MININT64, ERANGE);
1045   check_int64 ("32768", "", 10, 32768, 0);
1046   check_int64 ("-32768", "", 10, -32768, 0);
1047   check_int64 ("001", "", 10, 1, 0);
1048   check_int64 ("-001", "", 10, -1, 0);
1049 }
1050
1051 static void
1052 test_bounds (void)
1053 {
1054   GMappedFile *file, *before, *after;
1055   char buffer[4097];
1056   char *tmp, *tmp2;
1057   char **array;
1058   char *string;
1059
1060   /* if we allocate the file between two others and then free those
1061    * other two, then hopefully we end up with unmapped memory on either
1062    * side.
1063    */
1064   before = g_mapped_file_new ("4096-random-bytes", TRUE, NULL);
1065
1066   /* quick workaround until #549783 can be fixed */
1067   if (before == NULL)
1068     return;
1069
1070   file = g_mapped_file_new ("4096-random-bytes", TRUE, NULL);
1071   after = g_mapped_file_new ("4096-random-bytes", TRUE, NULL);
1072   g_mapped_file_free (before);
1073   g_mapped_file_free (after);
1074
1075   g_assert (file != NULL);
1076   g_assert_cmpint (g_mapped_file_get_length (file), ==, 4096);
1077   string = g_mapped_file_get_contents (file);
1078
1079   /* ensure they're all non-nul */
1080   g_assert (memchr (string, '\0', 4096) == NULL);
1081
1082   /* test set 1: ensure that nothing goes past its maximum length, even in
1083    *             light of a missing nul terminator.
1084    *
1085    * we try to test all of the 'n' functions here.
1086    */
1087   tmp = g_strndup (string, 4096);
1088   g_assert_cmpint (strlen (tmp), ==, 4096);
1089   g_free (tmp);
1090
1091   /* found no bugs in gnome, i hope :) */
1092   g_assert (g_strstr_len (string, 4096, "BUGS") == NULL);
1093   g_strstr_len (string, 4096, "B");
1094   g_strstr_len (string, 4096, ".");
1095   g_strstr_len (string, 4096, "");
1096
1097   g_strrstr_len (string, 4096, "BUGS");
1098   g_strrstr_len (string, 4096, "B");
1099   g_strrstr_len (string, 4096, ".");
1100   g_strrstr_len (string, 4096, "");
1101
1102   g_ascii_strdown (string, 4096);
1103   g_ascii_strdown (string, 4096);
1104   g_ascii_strup (string, 4096);
1105   g_ascii_strup (string, 4096);
1106
1107   g_ascii_strncasecmp (string, string, 4096);
1108
1109   tmp = g_markup_escape_text (string, 4096);
1110   g_free (tmp);
1111
1112   /* test set 2: ensure that nothing reads even one byte past a '\0'.
1113    */
1114   g_assert_cmpint (string[4095], ==, '\n');
1115   string[4095] = '\0';
1116
1117   tmp = g_strdup (string);
1118   g_assert_cmpint (strlen (tmp), ==, 4095);
1119   g_free (tmp);
1120
1121   tmp = g_strndup (string, 10000);
1122   g_assert_cmpint (strlen (tmp), ==, 4095);
1123   g_free (tmp);
1124
1125   g_stpcpy (buffer, string);
1126   g_assert_cmpint (strlen (buffer), ==, 4095);
1127
1128   g_strstr_len (string, 10000, "BUGS");
1129   g_strstr_len (string, 10000, "B");
1130   g_strstr_len (string, 10000, ".");
1131   g_strstr_len (string, 10000, "");
1132
1133   g_strrstr (string, "BUGS");
1134   g_strrstr (string, "B");
1135   g_strrstr (string, ".");
1136   g_strrstr (string, "");
1137
1138   g_strrstr_len (string, 10000, "BUGS");
1139   g_strrstr_len (string, 10000, "B");
1140   g_strrstr_len (string, 10000, ".");
1141   g_strrstr_len (string, 10000, "");
1142
1143   g_str_has_prefix (string, "this won't do very much...");
1144   g_str_has_suffix (string, "but maybe this will...");
1145   g_str_has_suffix (string, "HMMMM.");
1146   g_str_has_suffix (string, "MMMM.");
1147   g_str_has_suffix (string, "M.");
1148
1149   g_strlcpy (buffer, string, sizeof buffer);
1150   g_assert_cmpint (strlen (buffer), ==, 4095);
1151   g_strlcpy (buffer, string, sizeof buffer);
1152   buffer[0] = '\0';
1153   g_strlcat (buffer, string, sizeof buffer);
1154   g_assert_cmpint (strlen (buffer), ==, 4095);
1155
1156   tmp = g_strdup_printf ("<%s>", string);
1157   g_assert_cmpint (strlen (tmp), ==, 4095 + 2);
1158   g_free (tmp);
1159
1160   g_ascii_strdown (string, -1);
1161   g_ascii_strdown (string, -1);
1162   g_ascii_strup (string, -1);
1163   g_ascii_strup (string, -1);
1164
1165   g_ascii_strcasecmp (string, string);
1166   g_ascii_strncasecmp (string, string, 10000);
1167
1168   g_strreverse (string);
1169   g_strreverse (string);
1170   g_strchug (string);
1171   g_strchomp (string);
1172   g_strstrip (string);
1173   g_assert_cmpint (strlen (string), ==, 4095);
1174
1175   g_strdelimit (string, "M", 'N');
1176   g_strcanon (string, " N.", ':');
1177   g_assert_cmpint (strlen (string), ==, 4095);
1178
1179   array = g_strsplit (string, ".", -1);
1180   tmp = g_strjoinv (".", array);
1181   g_strfreev (array);
1182
1183   g_assert_cmpint (strlen (tmp), ==, 4095);
1184   g_assert (memcmp (tmp, string, 4095) == 0);
1185   g_free (tmp);
1186
1187   tmp = g_strconcat (string, string, string, NULL);
1188   g_assert_cmpint (strlen (tmp), ==, 4095 * 3);
1189   g_free (tmp);
1190
1191   tmp = g_strjoin ("!", string, string, NULL);
1192   g_assert_cmpint (strlen (tmp), ==, 4095 + 1 + 4095);
1193   g_free (tmp);
1194
1195   tmp = g_markup_escape_text (string, -1);
1196   g_free (tmp);
1197
1198   tmp = g_markup_printf_escaped ("%s", string);
1199   g_free (tmp);
1200
1201   tmp = g_strescape (string, NULL);
1202   tmp2 = g_strcompress (tmp);
1203   g_assert_cmpstr (string, ==, tmp2);
1204   g_free (tmp2);
1205   g_free (tmp);
1206
1207   g_mapped_file_free (file);
1208 }
1209
1210 int
1211 main (int   argc,
1212       char *argv[])
1213 {
1214   g_test_init (&argc, &argv, NULL);
1215
1216   g_test_add_func ("/strfuncs/test-is-to-digit", test_is_to_digit);
1217   g_test_add_func ("/strfuncs/strdup", test_strdup);
1218   g_test_add_func ("/strfuncs/strndup", test_strndup);
1219   g_test_add_func ("/strfuncs/strdup-printf", test_strdup_printf);
1220   g_test_add_func ("/strfuncs/strdupv", test_strdupv);
1221   g_test_add_func ("/strfuncs/strnfill", test_strnfill);
1222   g_test_add_func ("/strfuncs/strconcat", test_strconcat);
1223   g_test_add_func ("/strfuncs/strjoin", test_strjoin);
1224   g_test_add_func ("/strfuncs/strcanon", test_strcanon);
1225   g_test_add_func ("/strfuncs/strcompress-strescape", test_strcompress_strescape);
1226   g_test_add_func ("/strfuncs/ascii-strcasecmp", test_ascii_strcasecmp);
1227   g_test_add_func ("/strfuncs/strchug", test_strchug);
1228   g_test_add_func ("/strfuncs/strchomp", test_strchomp);
1229   g_test_add_func ("/strfuncs/strreverse", test_strreverse);
1230   g_test_add_func ("/strfuncs/strstr", test_strstr);
1231   g_test_add_func ("/strfuncs/has-prefix", test_has_prefix);
1232   g_test_add_func ("/strfuncs/has-suffix", test_has_suffix);
1233   g_test_add_func ("/strfuncs/strsplit", test_strsplit);
1234   g_test_add_func ("/strfuncs/strsplit-set", test_strsplit_set);
1235   g_test_add_func ("/strfuncs/strv-length", test_strv_length);
1236   g_test_add_func ("/strfuncs/strtod", test_strtod);
1237   g_test_add_func ("/strfuncs/strtoull-strtoll", test_strtoll);
1238   g_test_add_func ("/strfuncs/bounds-check", test_bounds);
1239
1240   return g_test_run();
1241 }