X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/4a9e1133c2a88d3d06f9a1d10a76cf0fbc049e8a..ca630f35f5db5b14af66fef9902f47f5f382b1fc:/src/xbt_str_unit.c diff --git a/src/xbt_str_unit.c b/src/xbt_str_unit.c index d34d8dcec1..669b5f1422 100644 --- a/src/xbt_str_unit.c +++ b/src/xbt_str_unit.c @@ -8,16 +8,18 @@ /* GENERATED FILE, DO NOT EDIT */ /*******************************/ -# 339 "xbt/xbt_str.c" +# 423 "xbt/xbt_str.c" +#include "xbt/str.h" + #define mytest(name, input, expected) \ xbt_test_add0(name); \ d=xbt_str_split_quoted(input); \ s=xbt_str_join(d,"XXX"); \ xbt_test_assert3(!strcmp(s,expected),\ - "Input (%s) leads to (%s) instead of (%s)", \ - input,s,expected);\ - free(s); \ - xbt_dynar_free(&d); + "Input (%s) leads to (%s) instead of (%s)", \ + input,s,expected);\ + free(s); \ + xbt_dynar_free(&d); XBT_TEST_UNIT("xbt_str_split_quoted",test_split_quoted, "test the function xbt_str_split_quoted") { xbt_dynar_t d; @@ -37,6 +39,27 @@ XBT_TEST_UNIT("xbt_str_split_quoted",test_split_quoted, "test the function xbt_s mytest("Backslashed quotes + quotes", "'toto \\'tutu' tata", "toto 'tutuXXXtata"); } + +#define mytest_str(name, input, separator, expected) \ + xbt_test_add0(name); \ + d=xbt_str_split_str(input, separator); \ + s=xbt_str_join(d,"XXX"); \ + xbt_test_assert3(!strcmp(s,expected),\ + "Input (%s) leads to (%s) instead of (%s)", \ + input,s,expected);\ + free(s); \ + xbt_dynar_free(&d); + +XBT_TEST_UNIT("xbt_str_split_str",test_split_str, "test the function xbt_str_split_str") { + xbt_dynar_t d; + char *s; + + mytest_str("Empty string and separator", "", "", ""); + mytest_str("Empty string", "", "##", ""); + mytest_str("Empty separator", "toto", "", "toto"); + mytest_str("String with no separator in it", "toto", "##", "toto"); + mytest_str("Basic test", "toto##tutu", "##", "totoXXXtutu"); +} /*******************************/ /* GENERATED FILE, DO NOT EDIT */ /*******************************/