added important test case to sstrsplit and fixed bug with consecutively occurring delimiters + fixed build system not linking test binary with newest library build

Mon, 26 Oct 2015 14:09:45 +0100

author
Mike Becker <universe@uap-core.de>
date
Mon, 26 Oct 2015 14:09:45 +0100
changeset 213
fa8b745be7b5
parent 212
c766c423dee6
child 214
2bc19726c340

added important test case to sstrsplit and fixed bug with consecutively occurring delimiters + fixed build system not linking test binary with newest library build

Makefile file | annotate | diff | comparison | revisions
test/Makefile file | annotate | diff | comparison | revisions
test/string_tests.c file | annotate | diff | comparison | revisions
ucx/string.c file | annotate | diff | comparison | revisions
     1.1 --- a/Makefile	Thu Oct 22 11:35:40 2015 +0200
     1.2 +++ b/Makefile	Mon Oct 26 14:09:45 2015 +0100
     1.3 @@ -49,16 +49,16 @@
     1.4  ucx-debug: FORCE
     1.5  	cd ucx; $(MAKE) CONF=$(CONF) debug
     1.6  	
     1.7 -test: FORCE ucx
     1.8 +test: ucx
     1.9  	cd test; $(MAKE) CONF=$(CONF)
    1.10  
    1.11 -test-debug: FORCE ucx-debug
    1.12 +test-debug: ucx-debug
    1.13  	cd test; $(MAKE) CONF=$(CONF) debug
    1.14  
    1.15 -run: FORCE test
    1.16 +run: test
    1.17  	./build/release/test/ucxtest$(APP_EXT)
    1.18  	
    1.19 -run-debug: FORCE test-debug
    1.20 +run-debug: test-debug
    1.21  	./build/debug/test/ucxtest$(APP_EXT)
    1.22  	
    1.23  debug: ucx-debug test-debug
     2.1 --- a/test/Makefile	Thu Oct 22 11:35:40 2015 +0200
     2.2 +++ b/test/Makefile	Mon Oct 26 14:09:45 2015 +0100
     2.3 @@ -47,7 +47,7 @@
     2.4  all: ../build/release/test ../build/release/test/ucxtest$(APP_EXT)
     2.5  debug: ../build/debug/test ../build/debug/test/ucxtest$(APP_EXT)
     2.6  
     2.7 -../build/release/test/ucxtest$(APP_EXT): $(OBJ)
     2.8 +../build/release/test/ucxtest$(APP_EXT): FORCE $(OBJ)
     2.9  	$(LD) $(LDFLAGS) -o ../build/release/test/ucxtest$(APP_EXT) \
    2.10  		$(OBJ) ../build/release/libucx$(LIB_EXT)
    2.11  
    2.12 @@ -57,7 +57,7 @@
    2.13  ../build/release/test:
    2.14  	$(MKDIR) $(MKDIRFLAGS) ../build/release/test
    2.15  
    2.16 -../build/debug/test/ucxtest$(APP_EXT): $(OBJ_D)
    2.17 +../build/debug/test/ucxtest$(APP_EXT): FORCE $(OBJ_D)
    2.18  	$(LD) $(LDFLAGS) -o ../build/debug/test/ucxtest$(APP_EXT) \
    2.19  		$(OBJ_D) ../build/debug/libucx$(LIB_EXT)
    2.20  
    2.21 @@ -66,3 +66,7 @@
    2.22  
    2.23  ../build/debug/test:
    2.24  	$(MKDIR) $(MKDIRFLAGS) ../build/debug/test
    2.25 +
    2.26 +# force rebuild of test binary (library might have been changed)
    2.27 +FORCE:
    2.28 +	
     3.1 --- a/test/string_tests.c	Thu Oct 22 11:35:40 2015 +0200
     3.2 +++ b/test/string_tests.c	Mon Oct 26 14:09:45 2015 +0100
     3.3 @@ -293,6 +293,19 @@
     3.4          free(list[i].ptr);
     3.5      }
     3.6      free(list);
     3.7 +    
     3.8 +    /* double encounter delimiter (ded) */
     3.9 +    n = 0;
    3.10 +    list = sstrsplit(test, S("is,"), &n);
    3.11 +    UCX_TEST_ASSERT(n == 3, "ded, list length must be 3");
    3.12 +    UCX_TEST_ASSERT(strcmp(list[0].ptr, "th") == 0, "ded, item 0 mismatch");
    3.13 +    UCX_TEST_ASSERT(list[1].length == 0, "ded, item 1 not empty!");
    3.14 +    UCX_TEST_ASSERT(strcmp(list[2].ptr, "a,csv,string") == 0,
    3.15 +        "ded, item 2 mismatch");
    3.16 +    for(int i=0;i<n;i++) {
    3.17 +        free(list[i].ptr);
    3.18 +    }
    3.19 +    free(list);
    3.20  
    3.21      UCX_TEST_END
    3.22  }
     4.1 --- a/ucx/string.c	Thu Oct 22 11:35:40 2015 +0200
     4.2 +++ b/ucx/string.c	Mon Oct 26 14:09:45 2015 +0100
     4.3 @@ -216,7 +216,7 @@
     4.4                  for (size_t j = 0 ; j < d.length ; j++) {
     4.5                      sv.ptr[i+j] = 0;
     4.6                  }
     4.7 -                i += d.length;
     4.8 +                i += d.length - 1; // -1, because the loop will do a i++
     4.9              }
    4.10          }
    4.11          if ((*n) == nmax) break;

mercurial