From: mquinson Date: Tue, 5 Jun 2007 09:08:53 +0000 (+0000) Subject: Add the new xbt/str testsuite to the autogenerated X-Git-Tag: v3.3~1802 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/043621276bcfe47f8089e22015ec1da99e6434db?hp=8a762701a2cdddc596e3dcfa65c8aae010c97599 Add the new xbt/str testsuite to the autogenerated git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@3558 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/simgrid_units_main.c b/src/simgrid_units_main.c index 65c53ef045..ff18a51eaf 100644 --- a/src/simgrid_units_main.c +++ b/src/simgrid_units_main.c @@ -45,6 +45,10 @@ extern xbt_test_unit_t _xbt_current_unit; void test_swag_basic(void); /* SGU: END FILE */ + /* SGU: BEGIN FILE xbt/xbt_str.c */ + void test_split_quoted(void); + /* SGU: END FILE */ + /* SGU: BEGIN FILE xbt/config.c */ void test_config_memuse(void); void test_config_validation(void); @@ -104,6 +108,11 @@ int main(int argc, char *argv[]) { xbt_test_suite_push(suite, "basic", test_swag_basic, "Basic usage"); /* SGU: END FILE */ + /* SGU: BEGIN FILE xbt/xbt_str.c */ + suite = xbt_test_suite_by_name("xbt_str","String Handling"); + xbt_test_suite_push(suite, "xbt_str_split_quoted", test_split_quoted, "test the function xbt_str_split_quoted"); + /* SGU: END FILE */ + /* SGU: BEGIN FILE xbt/config.c */ suite = xbt_test_suite_by_name("config","Configuration support"); xbt_test_suite_push(suite, "memuse", test_config_memuse, "Alloc and free a config set"); diff --git a/src/xbt_str_unit.c b/src/xbt_str_unit.c new file mode 100644 index 0000000000..13bbfbe60b --- /dev/null +++ b/src/xbt_str_unit.c @@ -0,0 +1,42 @@ +/*******************************/ +/* GENERATED FILE, DO NOT EDIT */ +/*******************************/ + +#include +#include "xbt.h" +/*******************************/ +/* GENERATED FILE, DO NOT EDIT */ +/*******************************/ + +# 339 "xbt/xbt_str.c" +#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); + +XBT_TEST_UNIT("xbt_str_split_quoted",test_split_quoted, "test the function xbt_str_split_quoted") { + xbt_dynar_t d; + char *s; + + mytest("Basic test", "toto tutu", "totoXXXtutu"); + mytest("Useless backslashes", "\\t\\o\\t\\o \\t\\u\\t\\u", "totoXXXtutu"); + mytest("Protected space", "toto\\ tutu", "toto tutu"); + mytest("Several spaces", "toto tutu", "totoXXXtutu"); + mytest("LTriming", " toto tatu", "totoXXXtatu"); + mytest("Triming", " toto tutu ", "totoXXXtutu"); + mytest("Single quotes", "'toto tutu' tata", "toto tutuXXXtata"); + mytest("Double quotes", "\"toto tutu\" tata", "toto tutuXXXtata"); + mytest("Mixed quotes", "\"toto' 'tutu\" tata", "toto' 'tutuXXXtata"); + mytest("Backslashed quotes", "\\'toto tutu\\' tata", "'totoXXXtutu'XXXtata"); + mytest("Backslashed quotes + quotes", "'toto \\'tutu' tata", "toto 'tutuXXXtata"); + +} +/*******************************/ +/* GENERATED FILE, DO NOT EDIT */ +/*******************************/ +