Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
renaming more tracing functions
[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 # 426 "/home/navarrop/Developments/simgrid/src/xbt/xbt_str.c" 
12 #include "xbt/str.h"
13
14 #define mytest(name, input, expected) \
15   xbt_test_add0(name); \
16   d=xbt_str_split_quoted(input); \
17   s=xbt_str_join(d,"XXX"); \
18   xbt_test_assert3(!strcmp(s,expected),\
19                    "Input (%s) leads to (%s) instead of (%s)", \
20                    input,s,expected);\
21                    free(s); \
22                    xbt_dynar_free(&d);
23
24 XBT_TEST_UNIT("xbt_str_split_quoted", test_split_quoted,"test the function xbt_str_split_quoted")
25 {
26   xbt_dynar_t d;
27   char *s;
28
29   mytest("Empty", "", "");
30   mytest("Basic test", "toto tutu", "totoXXXtutu");
31   mytest("Useless backslashes", "\\t\\o\\t\\o \\t\\u\\t\\u", "totoXXXtutu");
32   mytest("Protected space", "toto\\ tutu", "toto tutu");
33   mytest("Several spaces", "toto   tutu", "totoXXXtutu");
34   mytest("LTriming", "  toto tatu", "totoXXXtatu");
35   mytest("Triming", "  toto   tutu  ", "totoXXXtutu");
36   mytest("Single quotes", "'toto tutu' tata", "toto tutuXXXtata");
37   mytest("Double quotes", "\"toto tutu\" tata", "toto tutuXXXtata");
38   mytest("Mixed quotes", "\"toto' 'tutu\" tata", "toto' 'tutuXXXtata");
39   mytest("Backslashed quotes", "\\'toto tutu\\' tata",
40          "'totoXXXtutu'XXXtata");
41   mytest("Backslashed quotes + quotes", "'toto \\'tutu' tata",
42          "toto 'tutuXXXtata");
43
44 }
45
46 #define mytest_str(name, input, separator, expected) \
47   xbt_test_add0(name); \
48   d=xbt_str_split_str(input, separator); \
49   s=xbt_str_join(d,"XXX"); \
50   xbt_test_assert3(!strcmp(s,expected),\
51                    "Input (%s) leads to (%s) instead of (%s)", \
52                    input,s,expected);\
53                    free(s); \
54                    xbt_dynar_free(&d);
55
56 XBT_TEST_UNIT("xbt_str_split_str", test_split_str,"test the function xbt_str_split_str")
57 {
58   xbt_dynar_t d;
59   char *s;
60
61   mytest_str("Empty string and separator", "", "", "");
62   mytest_str("Empty string", "", "##", "");
63   mytest_str("Empty separator", "toto", "", "toto");
64   mytest_str("String with no separator in it", "toto", "##", "toto");
65   mytest_str("Basic test", "toto##tutu", "##", "totoXXXtutu");
66 }
67 /*******************************/
68 /* GENERATED FILE, DO NOT EDIT */
69 /*******************************/
70