Removed linked list from tests (assume that they are correct if the dlist tests are correct)

Wed, 11 Jan 2012 12:19:48 +0100

author
Mike Becker <universe@uap-core.de>
date
Wed, 11 Jan 2012 12:19:48 +0100
changeset 19
cdd7a3173249
parent 18
69636f81db31
child 21
d599fefc7620

Removed linked list from tests (assume that they are correct if the dlist tests are correct)

.hgignore file | annotate | diff | comparison | revisions
test/list_tests.c file | annotate | diff | comparison | revisions
test/list_tests.h file | annotate | diff | comparison | revisions
test/main.c file | annotate | diff | comparison | revisions
test/mpool_tests.c file | annotate | diff | comparison | revisions
--- a/.hgignore	Wed Jan 04 14:51:54 2012 +0100
+++ b/.hgignore	Wed Jan 11 12:19:48 2012 +0100
@@ -2,3 +2,4 @@
 ^nbproject/.*$
 ^build/.*$
 ^core$
+^.project$
--- a/test/list_tests.c	Wed Jan 04 14:51:54 2012 +0100
+++ b/test/list_tests.c	Wed Jan 11 12:19:48 2012 +0100
@@ -31,16 +31,6 @@
     return 0;
 }
 
-int list_tests_foreach(void *v, void *custom) {
-    UcxList *dl = (UcxList*)v;
-    struct test1_data *tdata = (struct test1_data*)custom;
-
-    tdata->values[tdata->i] = *(int*)dl->data;
-    tdata->i++;
-    
-    return 0;
-}
-
 int dlist_tests() {
     int r = 0;
     int v[8];
@@ -101,17 +91,21 @@
     dl2 = ucx_dlist_append(dl2, &v[4]);
     if (!ucx_dlist_equals(dl, dl2, NULL, NULL)) {
         fprintf(stderr, "ucx_dlist_equals failed (false negative)\n");
+        r--;
     }
     dl2->next->data = NULL;
     if (ucx_dlist_equals(dl, dl2, NULL, NULL)) {
         fprintf(stderr, "ucx_dlist_equals failed (false positive)\n");
+        r--;
     }
     dl2->next->data = &(tdata.values[1]);
     if (!ucx_dlist_equals(dl, dl2, int_cmp, NULL)) {
         fprintf(stderr, "ucx_dlist_equals failed (cmp_func false negative)\n");
+        r--;
     }
     if (ucx_dlist_equals(dl, dl2, NULL, NULL)) {
         fprintf(stderr, "ucx_dlist_equals failed (cmp_func false positive)\n");
+        r--;
     }
     ucx_dlist_free(dl2);
     
@@ -119,6 +113,7 @@
     dl2 = ucx_dlist_clone(dl, NULL, NULL);
     if (!ucx_dlist_equals(dl, dl2, NULL, NULL)) {
         fprintf(stderr, "ucx_dlist_clone (without copy) failed\n");
+        r--;
     }
     ucx_dlist_free(dl2);
     
@@ -127,88 +122,3 @@
     return r;
 }
 
-int list_tests() {
-    int r = 0;
-    int v[8];
-    UcxList *dl = NULL;
-    // build list 0,1,2,3,4,5,6,7
-    printf("   Test ucx_list_append\n");
-    fflush(stdout);
-    for(int i=0;i<8;i++) {
-        v[i] = i;
-        dl = ucx_list_append(dl, &v[i]);
-    }
-
-    printf("   Test ucx_list_get\n");
-    fflush(stdout);
-    for(int i=0;i<8;i++) {
-        UcxList *elm = ucx_list_get(dl, i);
-        if(elm == NULL) {
-            fprintf(stderr, "ucx_list_get failed: element is NULL\n");
-            r--;
-        }
-        if(elm->data == NULL) {
-            fprintf(stderr, "ucx_list_get failed: data is NULL\n");
-            r--;
-        }
-        int *data = (int*)elm->data;
-        if(*data != i) {
-            fprintf(stderr, "ucx_list_get failed with index %d\n", i);
-            r--;
-        }
-    }
-
-    printf("   Test ucx_list_free\n");
-    fflush(stdout);
-    ucx_list_free(dl);
-
-    dl = NULL;
-    // build list 4,0,4
-    printf("   Test ucx_list_prepend\n");
-    dl = ucx_list_prepend(dl, &v[0]);
-    dl = ucx_list_prepend(dl, &v[4]);
-    dl = ucx_list_append(dl, &v[4]);
-
-    struct test1_data tdata;
-    tdata.i = 0;
-    ucx_list_foreach(dl, list_tests_foreach, &tdata);
-
-    if(tdata.values[0] != 4 || tdata.values[1] != 0 || tdata.values[2] != 4) {
-        fprintf(stderr, "prepend/append test failed\n");
-        fprintf(stderr, "content: [%d, %d, %d]\n",
-                tdata.values[0], tdata.values[1], tdata.values[2]);
-        r--;
-    }
-    
-    printf("   Test ucx_list_equals\n");
-    UcxList *dl2 = NULL;
-    dl2 = ucx_list_append(dl2, &v[4]);
-    dl2 = ucx_list_append(dl2, &v[0]);
-    dl2 = ucx_list_append(dl2, &v[4]);
-    if (!ucx_list_equals(dl, dl2, NULL, NULL)) {
-        fprintf(stderr, "ucx_list_equals failed (false negative)\n");
-    }
-    dl2->next->data = NULL;
-    if (ucx_list_equals(dl, dl2, NULL, NULL)) {
-        fprintf(stderr, "ucx_list_equals failed (false positive)\n");
-    }
-    dl2->next->data = &(tdata.values[1]);
-    if (!ucx_list_equals(dl, dl2, int_cmp, NULL)) {
-        fprintf(stderr, "ucx_list_equals failed (cmp_func false negative)\n");
-    }
-    if (ucx_list_equals(dl, dl2, NULL, NULL)) {
-        fprintf(stderr, "ucx_list_equals failed (cmp_func false positive)\n");
-    }
-    ucx_list_free(dl2);
-    
-    printf("   Test ucx_list_clone\n");
-    dl2 = ucx_list_clone(dl, NULL, NULL);
-    if (!ucx_list_equals(dl, dl2, NULL, NULL)) {
-        fprintf(stderr, "ucx_list_clone (without copy) failed\n");
-    }
-    ucx_list_free(dl2);
-    
-    printf("   TODO: test clone with copy\n");
-
-    return r;
-}
--- a/test/list_tests.h	Wed Jan 04 14:51:54 2012 +0100
+++ b/test/list_tests.h	Wed Jan 11 12:19:48 2012 +0100
@@ -13,7 +13,6 @@
 #endif
 
 int dlist_tests();
-int list_tests();
 
 
 #ifdef	__cplusplus
--- a/test/main.c	Wed Jan 04 14:51:54 2012 +0100
+++ b/test/main.c	Wed Jan 11 12:19:48 2012 +0100
@@ -40,10 +40,7 @@
         fprintf(stderr, "dlist_tests failed\n");
     }
 
-    printf("\nUcxList Tests\n");
-    if(list_tests()) {
-        fprintf(stderr, "list_tests failed\n");
-    }
+    printf("\nUcxList Tests\n   Assumed to be correct\n");
 
     printf("\nUcxMemPool Tests\n");
     if(mpool_tests()) {
--- a/test/mpool_tests.c	Wed Jan 04 14:51:54 2012 +0100
+++ b/test/mpool_tests.c	Wed Jan 11 12:19:48 2012 +0100
@@ -25,6 +25,8 @@
 }
 
 int mpool_tests() {
+	int r = 0;
+
     printf("   Test ucx_mempool_new\n");
     UcxMempool *pool = ucx_mempool_new(16);
 
@@ -55,6 +57,7 @@
     char *str = ucx_mempool_calloc(pool, 1, 3);
     if(str[0] != 0 || str[1] != 0 || str[2] != 0) {
         fprintf(stderr, "ucx_mempool_calloc failed\n");
+        r--;
     }
     str[0] = 'O';
     str[1] = 'K';
@@ -65,6 +68,7 @@
     str[3] = 0;
     if(strcmp(str, "OK!") != 0) {
         fprintf(stderr, "Test ucx_mempool_realloc failed!\n");
+        r--;
     }
     
     printf("   Test ucx_mempool_reg_destr\n");
@@ -75,5 +79,5 @@
     //ucx_mempool_free(pool);
     
 
-    return 0;
+    return r;
 }

mercurial