# HG changeset patch # User Mike Becker # Date 1361970285 -3600 # Node ID 499e1b465d77eaadfd8b2fc400247d7ab5cbce0f # Parent fbbff331beba197e774f575416f0bb9a852046c7 fixed execution order of tests + added test for sstrtrim diff -r fbbff331beba -r 499e1b465d77 test/main.c --- a/test/main.c Wed Feb 27 13:53:28 2013 +0100 +++ b/test/main.c Wed Feb 27 14:04:45 2013 +0100 @@ -111,6 +111,12 @@ printf("\nLibrary function tests\n"); suite = ucx_test_suite_new(); + /* sstring Tests */ + ucx_test_register(suite, test_sstr); + ucx_test_register(suite, test_sstr_len_cat); + ucx_test_register(suite, test_sstrsplit); + ucx_test_register(suite, test_sstrtrim); + /* UcxLogger Tests */ ucx_test_register(suite, test_ucx_logger_log); @@ -162,11 +168,6 @@ ucx_test_register(suite, test_ucx_map_store_load_with_mempool); ucx_test_register(suite, test_ucx_map_clone); ucx_test_register(suite, test_ucx_map_rehash); - - /* sstring Tests */ - ucx_test_register(suite, test_sstr); - ucx_test_register(suite, test_sstr_len_cat); - ucx_test_register(suite, test_sstrsplit); /* UcxMemstream Tests */ ucx_test_register(suite, test_ucx_buffer_seektell); diff -r fbbff331beba -r 499e1b465d77 test/string_tests.c --- a/test/string_tests.c Wed Feb 27 13:53:28 2013 +0100 +++ b/test/string_tests.c Wed Feb 27 14:04:45 2013 +0100 @@ -174,3 +174,10 @@ UCX_TEST_END } + +UCX_TEST_IMPLEMENT(test_sstrtrim) { + sstr_t test = sstrtrim(sstr(" ein test ")); + UCX_TEST_BEGIN + UCX_TEST_ASSERT(strncmp(test.ptr, "ein test", test.length) == 0, "failed"); + UCX_TEST_END +} diff -r fbbff331beba -r 499e1b465d77 test/string_tests.h --- a/test/string_tests.h Wed Feb 27 13:53:28 2013 +0100 +++ b/test/string_tests.h Wed Feb 27 14:04:45 2013 +0100 @@ -15,6 +15,7 @@ UCX_TEST_DECLARE(test_sstr); UCX_TEST_DECLARE(test_sstr_len_cat); UCX_TEST_DECLARE(test_sstrsplit); +UCX_TEST_DECLARE(test_sstrtrim); #ifdef __cplusplus } diff -r fbbff331beba -r 499e1b465d77 ucx/string.c --- a/ucx/string.c Wed Feb 27 13:53:28 2013 +0100 +++ b/ucx/string.c Wed Feb 27 14:04:45 2013 +0100 @@ -176,7 +176,7 @@ sstr_t sstrtrim(sstr_t string) { sstr_t newstr = string; - int i; + size_t i; for(i=0;i 32) { diff -r fbbff331beba -r 499e1b465d77 ucx/test.c --- a/ucx/test.c Wed Feb 27 13:53:28 2013 +0100 +++ b/ucx/test.c Wed Feb 27 14:04:45 2013 +0100 @@ -29,11 +29,16 @@ int ucx_test_register(UcxTestSuite* suite, UcxTest test) { if (suite->tests) { - UcxTestList *list = (UcxTestList*) malloc(sizeof(UcxTestList)); - if (list) { - list->test = test; - list->next = suite->tests; - suite->tests = list; + UcxTestList *newelem = (UcxTestList*) malloc(sizeof(UcxTestList)); + if (newelem) { + newelem->test = test; + newelem->next = NULL; + + UcxTestList *last = suite->tests; + while (last->next) { + last = last->next; + } + last->next = newelem; return EXIT_SUCCESS; } else {