Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make dictionary internal table dynamic (and automatically resized).
[simgrid.git] / src / xbt_str_unit.c
1 /*******************************/
2 /* GENERATED FILE, DO NOT EDIT */
3 /*******************************/
4
5 #include <stdio.h>
6 #include "xbt.h"
7 /*******************************/
8 /* GENERATED FILE, DO NOT EDIT */
9 /*******************************/
10
11 # 387 "xbt/xbt_str.c" 
12 #define mytest(name, input, expected) \
13   xbt_test_add0(name); \
14   d=xbt_str_split_quoted(input); \
15   s=xbt_str_join(d,"XXX"); \
16   xbt_test_assert3(!strcmp(s,expected),\
17                    "Input (%s) leads to (%s) instead of (%s)", \
18                    input,s,expected);\
19   free(s); \
20   xbt_dynar_free(&d);
21
22 XBT_TEST_UNIT("xbt_str_split_quoted",test_split_quoted, "test the function xbt_str_split_quoted") {
23   xbt_dynar_t d;
24   char *s;
25
26   mytest("Empty", "", "");
27   mytest("Basic test", "toto tutu", "totoXXXtutu");
28   mytest("Useless backslashes", "\\t\\o\\t\\o \\t\\u\\t\\u", "totoXXXtutu");
29   mytest("Protected space", "toto\\ tutu", "toto tutu");
30   mytest("Several spaces", "toto   tutu", "totoXXXtutu");
31   mytest("LTriming", "  toto tatu", "totoXXXtatu");
32   mytest("Triming", "  toto   tutu  ", "totoXXXtutu");
33   mytest("Single quotes", "'toto tutu' tata", "toto tutuXXXtata");
34   mytest("Double quotes", "\"toto tutu\" tata", "toto tutuXXXtata");
35   mytest("Mixed quotes", "\"toto' 'tutu\" tata", "toto' 'tutuXXXtata");
36   mytest("Backslashed quotes", "\\'toto tutu\\' tata", "'totoXXXtutu'XXXtata");
37   mytest("Backslashed quotes + quotes", "'toto \\'tutu' tata", "toto 'tutuXXXtata");
38
39 }
40
41 #define mytest_str(name, input, separator, expected) \
42   xbt_test_add0(name); \
43   d=xbt_str_split_str(input, separator); \
44   s=xbt_str_join(d,"XXX"); \
45   xbt_test_assert3(!strcmp(s,expected),\
46                    "Input (%s) leads to (%s) instead of (%s)", \
47                    input,s,expected);\
48   free(s); \
49   xbt_dynar_free(&d);
50
51 XBT_TEST_UNIT("xbt_str_split_str",test_split_str, "test the function xbt_str_split_str") {
52   xbt_dynar_t d;
53   char *s;
54
55   mytest_str("Empty string and separator", "", "", "");
56   mytest_str("Empty string", "", "##", "");
57   mytest_str("Empty separator", "toto", "", "toto");
58   mytest_str("String with no separator in it", "toto", "##", "toto");
59   mytest_str("Basic test", "toto##tutu",  "##", "totoXXXtutu");
60 }
61 /*******************************/
62 /* GENERATED FILE, DO NOT EDIT */
63 /*******************************/
64