Sat, 18 Feb 2012 18:36:30 +0100
removed old foreach + refactored list tests
test/Makefile | file | annotate | diff | comparison | revisions | |
test/dlist_tests.c | file | annotate | diff | comparison | revisions | |
test/dlist_tests.h | 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/main.h | file | annotate | diff | comparison | revisions | |
ucx/dlist.c | file | annotate | diff | comparison | revisions | |
ucx/dlist.h | file | annotate | diff | comparison | revisions | |
ucx/list.c | file | annotate | diff | comparison | revisions | |
ucx/list.h | file | annotate | diff | comparison | revisions | |
ucx/test.h | file | annotate | diff | comparison | revisions |
--- a/test/Makefile Sat Feb 18 15:50:43 2012 +0100 +++ b/test/Makefile Sat Feb 18 18:36:30 2012 +0100 @@ -28,7 +28,7 @@ include ../$(CONF).mk -SRC = main.c list_tests.c mpool_tests.c map_tests.c +SRC = main.c list_tests.c dlist_tests.c mpool_tests.c map_tests.c OBJ = $(SRC:%.c=../build/%.$(OBJ_EXT))
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/dlist_tests.c Sat Feb 18 18:36:30 2012 +0100 @@ -0,0 +1,167 @@ +/* + * tests of dlist implementation + */ + +#include "dlist_tests.h" + +UCX_TEST_BEGIN(test_ucx_dlist_append) { + UcxDlist *list = ucx_dlist_append(NULL, "Hello"); + + UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed") + + list = ucx_dlist_append(list, " World!"); + + UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed") + UCX_TEST_ASSERT(list->next->next == NULL, "failed") + + ucx_dlist_free(list); + + UCX_TEST_END +} + +UCX_TEST_BEGIN(test_ucx_dlist_prepend) { + UcxDlist *list = ucx_dlist_prepend(NULL, " World!"); + list = ucx_dlist_prepend(list, "Hello"); + + UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed") + UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed") + UCX_TEST_ASSERT(list->next->next == NULL, "failed") + + ucx_dlist_free(list); + + UCX_TEST_END +} + +UCX_TEST_BEGIN(test_ucx_dlist_equals) { + UcxDlist *list = ucx_dlist_append(NULL, "Hello"); + list = ucx_dlist_append(list, " World!"); + UcxDlist *list2 = ucx_dlist_prepend(NULL, " World!"); + list2 = ucx_dlist_prepend(list2, "Hello"); + UcxDlist *list3 = ucx_dlist_prepend(NULL, " Welt!"); + list3 = ucx_dlist_prepend(list3, "Hallo"); + + UCX_TEST_ASSERT(ucx_dlist_equals(list, list2, cmp_string, NULL), "failed") + UCX_TEST_ASSERT(!ucx_dlist_equals(list, list3, cmp_string, NULL), "failed") + + ucx_dlist_free(list3); + ucx_dlist_free(list2); + ucx_dlist_free(list); + + UCX_TEST_END +} + +UCX_TEST_BEGIN(test_ucx_dlist_concat) { + UcxDlist *list = ucx_dlist_append(NULL, "Hello"); + UcxDlist *list2 = ucx_dlist_prepend(NULL, " World!"); + + list = ucx_dlist_concat(list, list2); + + UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed") + UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed") + UCX_TEST_ASSERT(list->next->next == NULL, "failed") + + ucx_dlist_free(list2); + ucx_dlist_free(list); + + UCX_TEST_END +} + +UCX_TEST_BEGIN(test_ucx_dlist_size) { + UcxDlist *list = ucx_dlist_append(NULL, "This "); + list = ucx_dlist_append(list, "list "); + list = ucx_dlist_append(list, "has "); + list = ucx_dlist_append(list, "size "); + list = ucx_dlist_append(list, "5!"); + + UCX_TEST_ASSERT(ucx_dlist_size(list) == 5, "failed"); + + ucx_dlist_free(list); + + UCX_TEST_END +} + +UCX_TEST_BEGIN(test_ucx_dlist_first) { + UcxDlist *list = ucx_dlist_append(NULL, "Find "); + list = ucx_dlist_append(list, "the "); + list = ucx_dlist_append(list, "first!"); + + char* first = (char*) (ucx_dlist_first(list)->data); + + UCX_TEST_ASSERT(strncmp(first, "Find ", 5) == 0, "failed"); + + ucx_dlist_free(list); + + UCX_TEST_END +} + +UCX_TEST_BEGIN(test_ucx_dlist_last) { + UcxDlist *list = ucx_dlist_append(NULL, "Find "); + list = ucx_dlist_append(list, "the "); + list = ucx_dlist_append(list, "last!"); + + char* last = (char*) (ucx_dlist_last(list)->data); + + UCX_TEST_ASSERT(strncmp(last, "last!", 5) == 0, "failed"); + + ucx_dlist_free(list); + + UCX_TEST_END +} + +UCX_TEST_BEGIN(test_ucx_dlist_get) { + UcxDlist *list = ucx_dlist_append(NULL, "Find "); + list = ucx_dlist_append(list, "the "); + list = ucx_dlist_append(list, "mid!"); + + char* mid = (char*) (ucx_dlist_get(list, 1)->data); + + UCX_TEST_ASSERT(strncmp(mid, "the ", 4) == 0, "failed"); + + ucx_dlist_free(list); + + UCX_TEST_END +} + +UCX_TEST_BEGIN(test_ucx_dlist_remove) { + UcxDlist *list = ucx_dlist_append(NULL, "Hello"); + list = ucx_dlist_append(list, " fucking"); + list = ucx_dlist_append(list, " World!"); + + list = ucx_dlist_remove(list, ucx_dlist_get(list, 1)); + + UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed") + UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed") + UCX_TEST_ASSERT(list->next->next == NULL, "failed") + + ucx_dlist_free(list); + + UCX_TEST_END +} + +UCX_TEST_BEGIN(test_ucx_dlist_clone) { + + char *hello = (char*)malloc(6); + char *world = (char*)malloc(8); + + memcpy(hello, "Hello", 6); + memcpy(world, " World!", 8); + + UcxDlist *list = ucx_dlist_append(NULL, hello); + list = ucx_dlist_append(list, world); + + UcxDlist *copy = ucx_dlist_clone(list, copy_string, NULL); + + UCX_TEST_ASSERT(ucx_dlist_equals(list, copy, cmp_string, NULL), "failed") + UCX_TEST_ASSERT(hello != copy->data, "first element is no copy") + UCX_TEST_ASSERT(world != copy->next->data, "second element is no copy") + + free(copy->next->data); + free(copy->data); + + free(world); + free(hello); + free(list); + free(copy); + + UCX_TEST_END +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/dlist_tests.h Sat Feb 18 18:36:30 2012 +0100 @@ -0,0 +1,41 @@ +/* + * File: dlist_tests.h + * Author: Mike + * + * Created on 18. Februar 2012, 18:26 + */ + +#ifndef DLIST_TESTS_H +#define DLIST_TESTS_H + +#include "main.h" + +#include "ucx/dlist.h" +#include "ucx/test.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Assumed to be correct: + * ucx_dlist_free + */ + +UCX_TEST_DECLARE(test_ucx_dlist_append) +UCX_TEST_DECLARE(test_ucx_dlist_prepend) +UCX_TEST_DECLARE(test_ucx_dlist_equals) +UCX_TEST_DECLARE(test_ucx_dlist_concat) +UCX_TEST_DECLARE(test_ucx_dlist_size) +UCX_TEST_DECLARE(test_ucx_dlist_first) +UCX_TEST_DECLARE(test_ucx_dlist_last) +UCX_TEST_DECLARE(test_ucx_dlist_get) +UCX_TEST_DECLARE(test_ucx_dlist_remove) +UCX_TEST_DECLARE(test_ucx_dlist_clone) + +#ifdef __cplusplus +} +#endif + +#endif /* DLIST_TESTS_H */ +
--- a/test/list_tests.c Sat Feb 18 15:50:43 2012 +0100 +++ b/test/list_tests.c Sat Feb 18 18:36:30 2012 +0100 @@ -2,177 +2,152 @@ * tests of list implementation */ -#include <stdio.h> -#include <stdlib.h> - -#include "ucx/list.h" -#include "ucx/dlist.h" +#include "list_tests.h" -struct foreach_testdata { - int values[3]; - int i; -}; +UCX_TEST_BEGIN(test_ucx_list_append) { + UcxList *list = ucx_list_append(NULL, "Hello"); + + UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed") + + list = ucx_list_append(list, " World!"); + + UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed") + UCX_TEST_ASSERT(list->next->next == NULL, "failed") + + ucx_list_free(list); + + UCX_TEST_END +} -void* int_cpy(void* source, void* data) { - void *dest = malloc(sizeof(int)); - if (dest != NULL) { - *((int*)dest) = *((int*)source); - } - return dest; +UCX_TEST_BEGIN(test_ucx_list_prepend) { + UcxList *list = ucx_list_prepend(NULL, " World!"); + list = ucx_list_prepend(list, "Hello"); + + UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed") + UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed") + UCX_TEST_ASSERT(list->next->next == NULL, "failed") + + ucx_list_free(list); + + UCX_TEST_END } -int int_cmp(void* e1, void *e2, void *data) { - if (e1 == NULL || e2 == NULL) return (e1 == e2) ? 0 : -1; - - int *i1 = (int*)e1, *i2 = (int*)e2; - int r = (*i1) - (*i2); - return (r < 0) ? -1 : (r == 0 ? 0 : 1); +UCX_TEST_BEGIN(test_ucx_list_equals) { + UcxList *list = ucx_list_append(NULL, "Hello"); + list = ucx_list_append(list, " World!"); + UcxList *list2 = ucx_list_prepend(NULL, " World!"); + list2 = ucx_list_prepend(list2, "Hello"); + UcxList *list3 = ucx_list_prepend(NULL, " Welt!"); + list3 = ucx_list_prepend(list3, "Hallo"); + + UCX_TEST_ASSERT(ucx_list_equals(list, list2, cmp_string, NULL), "failed") + UCX_TEST_ASSERT(!ucx_list_equals(list, list3, cmp_string, NULL), "failed") + + ucx_list_free(list3); + ucx_list_free(list2); + ucx_list_free(list); + + UCX_TEST_END } -int dlist_tests_foreach(void *v, void *custom) { - UcxDlist *dl = (UcxDlist*)v; - struct foreach_testdata *tdata = (struct foreach_testdata*)custom; - - tdata->values[tdata->i] = *(int*)dl->data; - tdata->i++; - - return 0; -} - -int dlist_free_content(void *v, void *custom) { - UcxDlist *dl = (UcxDlist*)v; - free(dl->data); - return 0; +UCX_TEST_BEGIN(test_ucx_list_concat) { + UcxList *list = ucx_list_append(NULL, "Hello"); + UcxList *list2 = ucx_list_prepend(NULL, " World!"); + + list = ucx_list_concat(list, list2); + + UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed") + UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed") + UCX_TEST_ASSERT(list->next->next == NULL, "failed") + + ucx_list_free(list2); + ucx_list_free(list); + + UCX_TEST_END } -int dlist_tests() { - int r = 0; - int v[8]; - UcxDlist *dl = NULL; - // build list 0,1,2,3,4,5,6,7 - printf(" Test ucx_dlist_append\n"); - fflush(stdout); - for(int i=0;i<8;i++) { - v[i] = i; - dl = ucx_dlist_append(dl, &v[i]); - } - - printf(" Test ucx_dlist_get\n"); - fflush(stdout); - for(int i=0;i<8;i++) { - UcxDlist *elm = ucx_dlist_get(dl, i); - if(elm == NULL) { - fprintf(stderr, "ucx_dlist_get failed: element is NULL\n"); - r--; - } else if(elm->data == NULL) { - fprintf(stderr, "ucx_dlist_get failed: data is NULL\n"); - r--; - } else { - int *data = (int*)elm->data; - if(*data != i) { - fprintf(stderr, "ucx_dlist_get failed with index %d\n", i); - r--; - } - } - } - - printf(" Test ucx_dlist_free\n"); - fflush(stdout); - ucx_dlist_free(dl); - - dl = NULL; - // build list 4,0,4 - printf(" Test ucx_dlist_prepend\n"); - dl = ucx_dlist_prepend(dl, &v[0]); - dl = ucx_dlist_prepend(dl, &v[4]); - dl = ucx_dlist_append(dl, &v[4]); - - struct foreach_testdata tdata; - tdata.i = 0; - ucx_dlist_foreach(dl, dlist_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--; - } +UCX_TEST_BEGIN(test_ucx_list_size) { + UcxList *list = ucx_list_append(NULL, "This "); + list = ucx_list_append(list, "list "); + list = ucx_list_append(list, "has "); + list = ucx_list_append(list, "size "); + list = ucx_list_append(list, "5!"); + + UCX_TEST_ASSERT(ucx_list_size(list) == 5, "failed"); + + ucx_list_free(list); + + UCX_TEST_END +} - printf(" Test ucx_dlist_equals\n"); - UcxDlist *dl2 = NULL; - dl2 = ucx_dlist_append(dl2, &v[4]); - dl2 = ucx_dlist_append(dl2, &v[0]); - 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); - - printf(" Test ucx_dlist_clone\n"); - 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); +UCX_TEST_BEGIN(test_ucx_list_last) { + UcxList *list = ucx_list_append(NULL, "Find "); + list = ucx_list_append(list, "the "); + list = ucx_list_append(list, "last!"); + + char* last = (char*) (ucx_list_last(list)->data); + + UCX_TEST_ASSERT(strncmp(last, "last!", 5) == 0, "failed"); + + ucx_list_free(list); + + UCX_TEST_END +} - printf(" Test ucx_dlist_clone with copy\n"); - dl2 = ucx_dlist_clone(dl, int_cpy, NULL); - if (!ucx_dlist_equals(dl, dl2, NULL, NULL)) { - if (!ucx_dlist_equals(dl, dl2, int_cmp, NULL)) { - fprintf(stderr, "ucx_dlist_clone (with copy) failed (compare)\n"); - r--; - } - } else { - fprintf(stderr, "ucx_dlist_clone (with copy) failed (identity)\n"); - r--; - } - ucx_dlist_foreach(dl, dlist_free_content, NULL); - ucx_dlist_free(dl2); - - ucx_dlist_free(dl); - - dl = NULL; - printf(" Test ucx_dlist_remove\n"); - dl = ucx_dlist_append(dl, &v[4]); - dl = ucx_dlist_append(dl, &v[0]); - dl = ucx_dlist_append(dl, &v[3]); - dl = ucx_dlist_remove(dl, dl->next); - if (ucx_dlist_size(dl) == 2) { - if ((*((int*)(dl->data)) != 4) || (*((int*)(dl->next->data)) != 3)) { - fprintf(stderr, "ucx_dlist_remove failed (wrong data)\n"); - r--; - } - } else { - fprintf(stderr, "ucx_dlist_remove failed (wrong size)\n"); - r--; - } - dl = ucx_dlist_remove(dl, dl); - if (ucx_dlist_size(dl) == 1) { - if ((*((int*)(dl->data)) != 3)) { - fprintf(stderr, "ucx_dlist_remove first failed (wrong data)\n"); - r--; - } - } else { - fprintf(stderr, "ucx_dlist_remove first failed (wrong size)\n"); - r--; - } - - return r; +UCX_TEST_BEGIN(test_ucx_list_get) { + UcxList *list = ucx_list_append(NULL, "Find "); + list = ucx_list_append(list, "the "); + list = ucx_list_append(list, "mid!"); + + char* mid = (char*) (ucx_list_get(list, 1)->data); + + UCX_TEST_ASSERT(strncmp(mid, "the ", 4) == 0, "failed"); + + ucx_list_free(list); + + UCX_TEST_END } +UCX_TEST_BEGIN(test_ucx_list_remove) { + UcxList *list = ucx_list_append(NULL, "Hello"); + list = ucx_list_append(list, " fucking"); + list = ucx_list_append(list, " World!"); + + list = ucx_list_remove(list, ucx_list_get(list, 1)); + + UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed") + UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed") + UCX_TEST_ASSERT(list->next->next == NULL, "failed") + + ucx_list_free(list); + + UCX_TEST_END +} + +UCX_TEST_BEGIN(test_ucx_list_clone) { + + char *hello = (char*)malloc(6); + char *world = (char*)malloc(8); + + memcpy(hello, "Hello", 6); + memcpy(world, " World!", 8); + + UcxList *list = ucx_list_append(NULL, hello); + list = ucx_list_append(list, world); + + UcxList *copy = ucx_list_clone(list, copy_string, NULL); + + UCX_TEST_ASSERT(ucx_list_equals(list, copy, cmp_string, NULL), "failed") + UCX_TEST_ASSERT(hello != copy->data, "first element is no copy") + UCX_TEST_ASSERT(world != copy->next->data, "second element is no copy") + + free(copy->next->data); + free(copy->data); + + free(world); + free(hello); + free(list); + free(copy); + + UCX_TEST_END +}
--- a/test/list_tests.h Sat Feb 18 15:50:43 2012 +0100 +++ b/test/list_tests.h Sat Feb 18 18:36:30 2012 +0100 @@ -8,12 +8,29 @@ #ifndef LIST_TESTS_H #define LIST_TESTS_H +#include "main.h" + +#include "ucx/list.h" +#include "ucx/test.h" + #ifdef __cplusplus extern "C" { #endif -int dlist_tests(); +/* + * Assumed to be correct: + * ucx_list_free + */ +UCX_TEST_DECLARE(test_ucx_list_append) +UCX_TEST_DECLARE(test_ucx_list_prepend) +UCX_TEST_DECLARE(test_ucx_list_equals) +UCX_TEST_DECLARE(test_ucx_list_concat) +UCX_TEST_DECLARE(test_ucx_list_size) +UCX_TEST_DECLARE(test_ucx_list_last) +UCX_TEST_DECLARE(test_ucx_list_get) +UCX_TEST_DECLARE(test_ucx_list_remove) +UCX_TEST_DECLARE(test_ucx_list_clone) #ifdef __cplusplus }
--- a/test/main.c Sat Feb 18 15:50:43 2012 +0100 +++ b/test/main.c Sat Feb 18 18:36:30 2012 +0100 @@ -31,10 +31,26 @@ #include "ucx/test.h" +#include "main.h" + #include "list_tests.h" +#include "dlist_tests.h" + #include "mpool_tests.h" #include "map_tests.h" +int cmp_string(void* o1, void* o2, void* data) { + return strcmp((char*)o1, (char*)o2); +} + +void* copy_string(void* e, void* data) { + char *str = (char*) e; + size_t n = 1+strlen(str); + char *cpy = (char*) malloc(n); + memcpy(cpy, str, n); + return cpy; +} + UCX_TEST_BEGIN(testTestSuitePositive) { UCX_TEST_ASSERT(2*2 == 4, "the test framework fails") UCX_TEST_END @@ -48,22 +64,39 @@ int main(int argc, char **argv) { printf("UCX Tests\n---------\n"); - printf("\nUcxTestSuite Tests\n"); + printf("\nUcxTestSuite Tests (1 failure is intended!)\n"); UcxTestSuite* suite = ucx_test_suite_new(); ucx_test_register(suite, testTestSuitePositive); ucx_test_register(suite, testTestSuiteNegative); ucx_test_run(suite, stdout); if (suite->failure == 1 && suite->success == 1) { ucx_test_suite_free(suite); - + + suite = ucx_test_suite_new(); + /* UcxList Tests */ + ucx_test_register(suite, test_ucx_list_append); + ucx_test_register(suite, test_ucx_list_prepend); + ucx_test_register(suite, test_ucx_list_equals); + ucx_test_register(suite, test_ucx_list_concat); + ucx_test_register(suite, test_ucx_list_size); + ucx_test_register(suite, test_ucx_list_last); + ucx_test_register(suite, test_ucx_list_get); + ucx_test_register(suite, test_ucx_list_remove); + ucx_test_register(suite, test_ucx_list_clone); + + /* UcxDlist Tests */ + ucx_test_register(suite, test_ucx_dlist_append); + ucx_test_register(suite, test_ucx_dlist_prepend); + ucx_test_register(suite, test_ucx_dlist_equals); + ucx_test_register(suite, test_ucx_dlist_concat); + ucx_test_register(suite, test_ucx_dlist_size); + ucx_test_register(suite, test_ucx_dlist_first); + ucx_test_register(suite, test_ucx_dlist_last); + ucx_test_register(suite, test_ucx_dlist_get); + ucx_test_register(suite, test_ucx_dlist_remove); + ucx_test_register(suite, test_ucx_dlist_clone); + /* TODO: replace these tests with "real" tests */ - printf("\nUcxDlist Tests\n"); - if(dlist_tests()) { - fprintf(stderr, "dlist_tests failed\n"); - } - - printf("\nUcxList Tests\n Assumed to be correct\n"); - printf("\nUcxMemPool Tests\n"); if(mpool_tests()) { fprintf(stderr, "mpool_tests failed\n"); @@ -74,6 +107,9 @@ fprintf(stderr, "map_tests failed\n"); } + ucx_test_run(suite, stdout); + ucx_test_suite_free(suite); + return EXIT_SUCCESS; } else { ucx_test_suite_free(suite);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/main.h Sat Feb 18 18:36:30 2012 +0100 @@ -0,0 +1,25 @@ +/* + * File: main.h + * Author: Mike + * + * Created on 18. Februar 2012, 18:33 + */ + +#ifndef MAIN_H +#define MAIN_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Some functions that are shared over the test */ +int cmp_string(void*, void*, void*); +void* copy_string(void*, void*); + + +#ifdef __cplusplus +} +#endif + +#endif /* MAIN_H */ +
--- a/ucx/dlist.c Sat Feb 18 15:50:43 2012 +0100 +++ b/ucx/dlist.c Sat Feb 18 18:36:30 2012 +0100 @@ -112,16 +112,6 @@ return s; } -void ucx_dlist_foreach(UcxDlist *l, ucx_callback fnc, void* data) { - UcxDlist *e = l; - UcxDlist *n; - while (e != NULL) { - n = e->next; - fnc(e, data); - e = n; - } -} - /* dlist specific functions */ UcxDlist *ucx_dlist_first(UcxDlist *l) { if (l == NULL) return NULL;
--- a/ucx/dlist.h Sat Feb 18 15:50:43 2012 +0100 +++ b/ucx/dlist.h Sat Feb 18 18:36:30 2012 +0100 @@ -29,7 +29,6 @@ UcxDlist *ucx_dlist_last(UcxDlist *l); UcxDlist *ucx_dlist_get(UcxDlist *l, int index); size_t ucx_dlist_size(UcxDlist *l); -void ucx_dlist_foreach(UcxDlist *l, ucx_callback fnc, void* data); /* dlist specific functions */ UcxDlist *ucx_dlist_first(UcxDlist *l);
--- a/ucx/list.c Sat Feb 18 15:50:43 2012 +0100 +++ b/ucx/list.c Sat Feb 18 18:36:30 2012 +0100 @@ -108,16 +108,6 @@ return s; } -void ucx_list_foreach(UcxList *l, ucx_callback fnc, void* data) { - UcxList *e = l; - UcxList *n; - while (e != NULL) { - n = e->next; - fnc(e, data); - e = n; - } -} - /* list specific functions */ UcxList *ucx_list_remove(UcxList *l, UcxList *e) { if (e == l) {
--- a/ucx/list.h Sat Feb 18 15:50:43 2012 +0100 +++ b/ucx/list.h Sat Feb 18 18:36:30 2012 +0100 @@ -28,7 +28,6 @@ UcxList *ucx_list_last(UcxList *l); UcxList *ucx_list_get(UcxList *l, int index); size_t ucx_list_size(UcxList *l); -void ucx_list_foreach(UcxList *l, ucx_callback fnc, void *data); /* list specific functions */ UcxList *ucx_list_remove(UcxList *l, UcxList *e);
--- a/ucx/test.h Sat Feb 18 15:50:43 2012 +0100 +++ b/ucx/test.h Sat Feb 18 18:36:30 2012 +0100 @@ -30,6 +30,7 @@ void ucx_test_register(UcxTestSuite*, UcxTest); void ucx_test_run(UcxTestSuite*, FILE*); +#define UCX_TEST_DECLARE(name) void name(UcxTestSuite*,FILE *); #define UCX_TEST_BEGIN(name) void name(UcxTestSuite* _suite_,FILE *_output_) {\ fwrite("Running "#name"... ", 1, 12+strlen(#name), _output_);