# HG changeset patch # User Mike Becker # Date 1487603054 -3600 # Node ID 5f2d650eade7df950a13d63c261576dd1b9e75b1 # Parent 35490eb48214c57eb37d4dfa92f5f47f85a5c9b0 adds new test case for sstrsplit: string ends with delimiter but empty string exceeds list bound diff -r 35490eb48214 -r 5f2d650eade7 test/string_tests.c --- a/test/string_tests.c Mon Feb 20 15:25:28 2017 +0100 +++ b/test/string_tests.c Mon Feb 20 16:04:14 2017 +0100 @@ -283,7 +283,7 @@ list = sstrsplit(test, S("string"), &n); UCX_TEST_ASSERT(n == 2, "ewd, list length must be 2"); UCX_TEST_ASSERT(strcmp(list[0].ptr, "this,is,a,csv,") == 0, - "swd, first item corrupt"); + "ewd, first item corrupt"); 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"); @@ -291,6 +291,19 @@ free(list[i].ptr); } free(list); + + /* end with delimiter exceed bound (ewdeb) */ + n = 3; + sstr_t ewdebtest = ST("a,b,c,"); + list = sstrsplit(ewdebtest, S(","), &n); + UCX_TEST_ASSERT(n == 3, "ewdeb, list length must be 3"); + UCX_TEST_ASSERT(strcmp(list[0].ptr, "a") == 0, "ewdeb, fst item corrupt"); + UCX_TEST_ASSERT(strcmp(list[1].ptr, "b") == 0, "ewdeb, snd item corrupt"); + UCX_TEST_ASSERT(strcmp(list[2].ptr, "c") == 0, "ewdeb, trd item corrupt"); + for(int i=0;i