Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add the new xbt/str testsuite to the autogenerated
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 5 Jun 2007 09:08:53 +0000 (09:08 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 5 Jun 2007 09:08:53 +0000 (09:08 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@3558 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/simgrid_units_main.c
src/xbt_str_unit.c [new file with mode: 0644]

index 65c53ef..ff18a51 100644 (file)
@@ -45,6 +45,10 @@ extern xbt_test_unit_t _xbt_current_unit;
     void test_swag_basic(void);
   /* SGU: END FILE */
 
     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);
   /* 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 */
 
       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");
     /* 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 (file)
index 0000000..13bbfbe
--- /dev/null
@@ -0,0 +1,42 @@
+/*******************************/
+/* GENERATED FILE, DO NOT EDIT */
+/*******************************/
+
+#include <stdio.h>
+#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 */
+/*******************************/
+