Browse Source

add "make check" target and make it work :)

master
Felix von Leitner 12 months ago
parent
commit
da34bb9603
  1. 7
      GNUmakefile
  2. 16
      scan/scan_8longn.c
  3. 7
      textcode/fmt_jsonescape.c
  4. 1
      textcode/scan_cescape.c
  5. 1
      textcode/scan_ldapescape.c

7
GNUmakefile

@ -381,7 +381,7 @@ windoze:
$(MAKE) DIET= CROSS=i686-mingw32-
windoze64:
$(MAKE) DIET= CROSS=x86_64-mingw32-
$(MAKE) DIET= CROSS=x86_64-w64-mingw32-
update:
dl -n http://www.w3.org/TR/html5/entities.json
@ -398,3 +398,8 @@ sa1:
sa2:
$(MAKE) clean
$(MAKE) DIET= CC="gcc -fanalyzer" -j8
UNITTESTS=$(shell grep -l UNITTEST */*.c)
check: haveuint128.h haveinline.h entities.h
for i in $(UNITTESTS); do $(DIET) $(CCC) -g -o t -DUNITTEST $$i -I. $(LDFLAGS) && ./t || echo FAIL $$i ; done

16
scan/scan_8longn.c

@ -26,17 +26,17 @@ size_t scan_8longn(const char *src,size_t n,unsigned long *dest) {
int main() {
unsigned long i;
assert(scan_8longn("1234",100,&i)==4 && i==01234);
assert(scan_8longn("12345678",100,&i)==7 && i==01234567);
assert(scan_8longn("1234\0""67890",10,&i)==4 && i==01234);
assert(scan_8longn("12345678",9,&i)==7 && i==01234567);
if (sizeof(long)==sizeof(int)) {
assert(scan_8longn("37777777777",100,&i)==11 && i==0xffffffff);
assert(scan_8longn("40000000000",100,&i)==10 && i==04000000000);
assert(scan_8longn("37777777777",12,&i)==11 && i==0xffffffff);
assert(scan_8longn("40000000000",12,&i)==10 && i==04000000000);
} else if (sizeof(long)==sizeof(long long)) {
assert(scan_8longn("1777777777777777777777",100,&i)==22 && i==0xffffffffffffffffull);
assert(scan_8longn("2000000000000000000000",100,&i)==21 && i==0200000000000000000000ull);
assert(scan_8longn("1777777777777777777777",23,&i)==22 && i==0xffffffffffffffffull);
assert(scan_8longn("2000000000000000000000",23,&i)==21 && i==0200000000000000000000ull);
}
assert(scan_8longn("-4",100,&i)==0 && i==0);
assert(scan_8longn("01234",100,&i)==5 && i==01234);
assert(scan_8longn("-4",3,&i)==0 && i==0);
assert(scan_8longn("01234",6,&i)==5 && i==01234);
assert(scan_8longn("1234",2,&i)==2 && i==012);
return 0;
}

7
textcode/fmt_jsonescape.c

@ -93,6 +93,13 @@ noneed:
#include <assert.h>
#include <string.h>
#undef UNITTEST
#include "fmt/fmt_tohex.c"
#include "case/case_diffb.c"
#include "fmt/fmt_utf8.c"
#include "scan/scan_utf8_sem.c"
#include "scan/scan_utf8.c"
int main() {
char buf[100];
/* test utf-8 pass-through and correct encoding of \t */

1
textcode/scan_cescape.c

@ -77,6 +77,7 @@ error:
#ifdef UNITTEST
#include <assert.h>
#include <string.h>
#undef UNITTEST
#include <scan/scan_fromhex.c>
#include <fmt/fmt_utf8.c>

1
textcode/scan_ldapescape.c

@ -26,6 +26,7 @@ size_t scan_ldapescape(const char *src,char *dest,size_t *destlen) {
#ifdef UNITTEST
#include <assert.h>
#include <string.h>
#undef UNITTEST
#include <scan/scan_fromhex.c>

Loading…
Cancel
Save