Wed, 11 Jan 2012 12:19:48 +0100
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 |
1.1 --- a/.hgignore Wed Jan 04 14:51:54 2012 +0100 1.2 +++ b/.hgignore Wed Jan 11 12:19:48 2012 +0100 1.3 @@ -2,3 +2,4 @@ 1.4 ^nbproject/.*$ 1.5 ^build/.*$ 1.6 ^core$ 1.7 +^.project$
2.1 --- a/test/list_tests.c Wed Jan 04 14:51:54 2012 +0100 2.2 +++ b/test/list_tests.c Wed Jan 11 12:19:48 2012 +0100 2.3 @@ -31,16 +31,6 @@ 2.4 return 0; 2.5 } 2.6 2.7 -int list_tests_foreach(void *v, void *custom) { 2.8 - UcxList *dl = (UcxList*)v; 2.9 - struct test1_data *tdata = (struct test1_data*)custom; 2.10 - 2.11 - tdata->values[tdata->i] = *(int*)dl->data; 2.12 - tdata->i++; 2.13 - 2.14 - return 0; 2.15 -} 2.16 - 2.17 int dlist_tests() { 2.18 int r = 0; 2.19 int v[8]; 2.20 @@ -101,17 +91,21 @@ 2.21 dl2 = ucx_dlist_append(dl2, &v[4]); 2.22 if (!ucx_dlist_equals(dl, dl2, NULL, NULL)) { 2.23 fprintf(stderr, "ucx_dlist_equals failed (false negative)\n"); 2.24 + r--; 2.25 } 2.26 dl2->next->data = NULL; 2.27 if (ucx_dlist_equals(dl, dl2, NULL, NULL)) { 2.28 fprintf(stderr, "ucx_dlist_equals failed (false positive)\n"); 2.29 + r--; 2.30 } 2.31 dl2->next->data = &(tdata.values[1]); 2.32 if (!ucx_dlist_equals(dl, dl2, int_cmp, NULL)) { 2.33 fprintf(stderr, "ucx_dlist_equals failed (cmp_func false negative)\n"); 2.34 + r--; 2.35 } 2.36 if (ucx_dlist_equals(dl, dl2, NULL, NULL)) { 2.37 fprintf(stderr, "ucx_dlist_equals failed (cmp_func false positive)\n"); 2.38 + r--; 2.39 } 2.40 ucx_dlist_free(dl2); 2.41 2.42 @@ -119,6 +113,7 @@ 2.43 dl2 = ucx_dlist_clone(dl, NULL, NULL); 2.44 if (!ucx_dlist_equals(dl, dl2, NULL, NULL)) { 2.45 fprintf(stderr, "ucx_dlist_clone (without copy) failed\n"); 2.46 + r--; 2.47 } 2.48 ucx_dlist_free(dl2); 2.49 2.50 @@ -127,88 +122,3 @@ 2.51 return r; 2.52 } 2.53 2.54 -int list_tests() { 2.55 - int r = 0; 2.56 - int v[8]; 2.57 - UcxList *dl = NULL; 2.58 - // build list 0,1,2,3,4,5,6,7 2.59 - printf(" Test ucx_list_append\n"); 2.60 - fflush(stdout); 2.61 - for(int i=0;i<8;i++) { 2.62 - v[i] = i; 2.63 - dl = ucx_list_append(dl, &v[i]); 2.64 - } 2.65 - 2.66 - printf(" Test ucx_list_get\n"); 2.67 - fflush(stdout); 2.68 - for(int i=0;i<8;i++) { 2.69 - UcxList *elm = ucx_list_get(dl, i); 2.70 - if(elm == NULL) { 2.71 - fprintf(stderr, "ucx_list_get failed: element is NULL\n"); 2.72 - r--; 2.73 - } 2.74 - if(elm->data == NULL) { 2.75 - fprintf(stderr, "ucx_list_get failed: data is NULL\n"); 2.76 - r--; 2.77 - } 2.78 - int *data = (int*)elm->data; 2.79 - if(*data != i) { 2.80 - fprintf(stderr, "ucx_list_get failed with index %d\n", i); 2.81 - r--; 2.82 - } 2.83 - } 2.84 - 2.85 - printf(" Test ucx_list_free\n"); 2.86 - fflush(stdout); 2.87 - ucx_list_free(dl); 2.88 - 2.89 - dl = NULL; 2.90 - // build list 4,0,4 2.91 - printf(" Test ucx_list_prepend\n"); 2.92 - dl = ucx_list_prepend(dl, &v[0]); 2.93 - dl = ucx_list_prepend(dl, &v[4]); 2.94 - dl = ucx_list_append(dl, &v[4]); 2.95 - 2.96 - struct test1_data tdata; 2.97 - tdata.i = 0; 2.98 - ucx_list_foreach(dl, list_tests_foreach, &tdata); 2.99 - 2.100 - if(tdata.values[0] != 4 || tdata.values[1] != 0 || tdata.values[2] != 4) { 2.101 - fprintf(stderr, "prepend/append test failed\n"); 2.102 - fprintf(stderr, "content: [%d, %d, %d]\n", 2.103 - tdata.values[0], tdata.values[1], tdata.values[2]); 2.104 - r--; 2.105 - } 2.106 - 2.107 - printf(" Test ucx_list_equals\n"); 2.108 - UcxList *dl2 = NULL; 2.109 - dl2 = ucx_list_append(dl2, &v[4]); 2.110 - dl2 = ucx_list_append(dl2, &v[0]); 2.111 - dl2 = ucx_list_append(dl2, &v[4]); 2.112 - if (!ucx_list_equals(dl, dl2, NULL, NULL)) { 2.113 - fprintf(stderr, "ucx_list_equals failed (false negative)\n"); 2.114 - } 2.115 - dl2->next->data = NULL; 2.116 - if (ucx_list_equals(dl, dl2, NULL, NULL)) { 2.117 - fprintf(stderr, "ucx_list_equals failed (false positive)\n"); 2.118 - } 2.119 - dl2->next->data = &(tdata.values[1]); 2.120 - if (!ucx_list_equals(dl, dl2, int_cmp, NULL)) { 2.121 - fprintf(stderr, "ucx_list_equals failed (cmp_func false negative)\n"); 2.122 - } 2.123 - if (ucx_list_equals(dl, dl2, NULL, NULL)) { 2.124 - fprintf(stderr, "ucx_list_equals failed (cmp_func false positive)\n"); 2.125 - } 2.126 - ucx_list_free(dl2); 2.127 - 2.128 - printf(" Test ucx_list_clone\n"); 2.129 - dl2 = ucx_list_clone(dl, NULL, NULL); 2.130 - if (!ucx_list_equals(dl, dl2, NULL, NULL)) { 2.131 - fprintf(stderr, "ucx_list_clone (without copy) failed\n"); 2.132 - } 2.133 - ucx_list_free(dl2); 2.134 - 2.135 - printf(" TODO: test clone with copy\n"); 2.136 - 2.137 - return r; 2.138 -}
3.1 --- a/test/list_tests.h Wed Jan 04 14:51:54 2012 +0100 3.2 +++ b/test/list_tests.h Wed Jan 11 12:19:48 2012 +0100 3.3 @@ -13,7 +13,6 @@ 3.4 #endif 3.5 3.6 int dlist_tests(); 3.7 -int list_tests(); 3.8 3.9 3.10 #ifdef __cplusplus
4.1 --- a/test/main.c Wed Jan 04 14:51:54 2012 +0100 4.2 +++ b/test/main.c Wed Jan 11 12:19:48 2012 +0100 4.3 @@ -40,10 +40,7 @@ 4.4 fprintf(stderr, "dlist_tests failed\n"); 4.5 } 4.6 4.7 - printf("\nUcxList Tests\n"); 4.8 - if(list_tests()) { 4.9 - fprintf(stderr, "list_tests failed\n"); 4.10 - } 4.11 + printf("\nUcxList Tests\n Assumed to be correct\n"); 4.12 4.13 printf("\nUcxMemPool Tests\n"); 4.14 if(mpool_tests()) {
5.1 --- a/test/mpool_tests.c Wed Jan 04 14:51:54 2012 +0100 5.2 +++ b/test/mpool_tests.c Wed Jan 11 12:19:48 2012 +0100 5.3 @@ -25,6 +25,8 @@ 5.4 } 5.5 5.6 int mpool_tests() { 5.7 + int r = 0; 5.8 + 5.9 printf(" Test ucx_mempool_new\n"); 5.10 UcxMempool *pool = ucx_mempool_new(16); 5.11 5.12 @@ -55,6 +57,7 @@ 5.13 char *str = ucx_mempool_calloc(pool, 1, 3); 5.14 if(str[0] != 0 || str[1] != 0 || str[2] != 0) { 5.15 fprintf(stderr, "ucx_mempool_calloc failed\n"); 5.16 + r--; 5.17 } 5.18 str[0] = 'O'; 5.19 str[1] = 'K'; 5.20 @@ -65,6 +68,7 @@ 5.21 str[3] = 0; 5.22 if(strcmp(str, "OK!") != 0) { 5.23 fprintf(stderr, "Test ucx_mempool_realloc failed!\n"); 5.24 + r--; 5.25 } 5.26 5.27 printf(" Test ucx_mempool_reg_destr\n"); 5.28 @@ -75,5 +79,5 @@ 5.29 //ucx_mempool_free(pool); 5.30 5.31 5.32 - return 0; 5.33 + return r; 5.34 }