test/string_tests.c

changeset 147
1aa598f36872
parent 146
aa376dba1ba8
child 148
c27c2425c0b1
--- a/test/string_tests.c	Fri Aug 16 13:40:10 2013 +0200
+++ b/test/string_tests.c	Fri Aug 16 14:48:58 2013 +0200
@@ -91,6 +91,9 @@
             "original string shall be returned as single list element");
     UCX_TEST_ASSERT(strcmp(test.ptr, original) == 0,
                 "ndo, original has been modified");
+    for(int i=0;i<n;i++) {
+        free(list[i].ptr);
+    }
     free(list);
 
     /* partially matching delimiter (pmd) */
@@ -101,6 +104,9 @@
             "original string shall be returned as single list element");
     UCX_TEST_ASSERT(strcmp(test.ptr, original) == 0,
                 "pmd, original has been modified");
+    for(int i=0;i<n;i++) {
+        free(list[i].ptr);
+    }
     free(list);
 
     /* matching single-char delimiter (mscd) */
@@ -114,6 +120,9 @@
     UCX_TEST_ASSERT(strcmp(list[4].ptr, "string")==0, "mscd, item 4 mismatch");
     UCX_TEST_ASSERT(strcmp(test.ptr, original) == 0,
             "mscd, original has been modified");
+    for(int i=0;i<n;i++) {
+        free(list[i].ptr);
+    }
     free(list);
 
     /* matching multi-char delimiter (mmcd) */
@@ -126,6 +135,9 @@
             "mmcd, item 2 mismatch");
     UCX_TEST_ASSERT(strcmp(test.ptr, original) == 0,
             "mmcd, original has been modified");
+    for(int i=0;i<n;i++) {
+        free(list[i].ptr);
+    }
     free(list);
 
     /* bounded list using single-char delimiter (blsc) */
@@ -138,6 +150,9 @@
             "blsc, item 2 mismatch");
     UCX_TEST_ASSERT(strcmp(test.ptr, original) == 0,
             "blsc, original has been modified");
+    for(int i=0;i<n;i++) {
+        free(list[i].ptr);
+    }
     free(list);
 
     /* bounded list using multi-char delimiter (blmc) */
@@ -149,6 +164,9 @@
             "blmc, item 1 mismatch");
     UCX_TEST_ASSERT(strcmp(test.ptr, original) == 0,
             "blmc, original has been modified");
+    for(int i=0;i<n;i++) {
+        free(list[i].ptr);
+    }
     free(list);
 
     /* start with delimiter (swd) */
@@ -160,6 +178,9 @@
             "swd, second item corrupt");
     UCX_TEST_ASSERT(strcmp(test.ptr, original) == 0,
             "swd, original has been modified");
+    for(int i=0;i<n;i++) {
+        free(list[i].ptr);
+    }
     free(list);
 
     /* end with delimiter (ewd) */
@@ -171,6 +192,9 @@
     UCX_TEST_ASSERT(list[1].length == 0, "ewd, second item must be empty");
     UCX_TEST_ASSERT(strcmp(test.ptr, original) == 0,
             "ewd, original has been modified");
+    for(int i=0;i<n;i++) {
+        free(list[i].ptr);
+    }
     free(list);
 
     /* exact match (exm) */
@@ -178,6 +202,9 @@
     list = sstrsplit(test, S("this,is,a,csv,string"), &n);
     UCX_TEST_ASSERT(n == 0, "exm, list length must be 0");
     UCX_TEST_ASSERT(list == NULL, "exm, list must be NULL");
+    for(int i=0;i<n;i++) {
+        free(list[i].ptr);
+    }
     free(list);
 
     /* substring (subs) */
@@ -188,6 +215,9 @@
             "subs, single item must be the original string");
     UCX_TEST_ASSERT(strcmp(test.ptr, original) == 0,
             "subs, original has been modified");
+    for(int i=0;i<n;i++) {
+        free(list[i].ptr);
+    }
     free(list);
 
     UCX_TEST_END

mercurial