diff --git a/lib/fec.c b/lib/fec.c index 4097e98..a392901 100644 --- a/lib/fec.c +++ b/lib/fec.c @@ -46,6 +46,7 @@ #include #include +typedef unsigned long u_long; /* * compatibility stuff */ diff --git a/main.cpp b/main.cpp index 14f29d9..1ab0e1a 100644 --- a/main.cpp +++ b/main.cpp @@ -923,6 +923,42 @@ int event_loop() myexit(0); return 0; } +int unit_test() +{ + int i,j,k; + void *code=fec_new(3,6); + char arr[6][100]= + { + "aaa","bbb","ccc" + ,"ddd","eee","fff" + }; + char *data[6]; + for(i=0;i<6;i++) + { + data[i]=arr[i]; + } + rs_encode(code,data,3); + printf("%d %d",(int)(unsigned char)arr[5][0],(int)('a'^'b'^'c'^'d'^'e')); + + for(i=0;i<6;i++) + { + printf("<%s>",data[i]); + } + + data[0]=0; + data[1]=0; + data[2]=0; + + int ret=rs_decode(code,data,3); + printf("ret:%d\n",ret); + + for(i=0;i<6;i++) + { + printf("<%s>",data[i]); + } + fec_free(code); + return 0; +} void print_help() { char git_version_buf[100]={0}; @@ -987,6 +1023,14 @@ void process_arg(int argc, char *argv[]) myexit( -1); } for (i = 0; i < argc; i++) + { + if(strcmp(argv[i],"--unit-test")==0) + { + unit_test(); + myexit(0); + } + } + for (i = 0; i < argc; i++) { if(strcmp(argv[i],"-h")==0||strcmp(argv[i],"--help")==0) { @@ -1232,6 +1276,7 @@ void process_arg(int argc, char *argv[]) myexit(-1); } } + int main(int argc, char *argv[]) { assert(sizeof(u64_t)==8); diff --git a/makefile b/makefile index 9855d6a..086e918 100755 --- a/makefile +++ b/makefile @@ -8,7 +8,7 @@ cc_arm= /toolchains/arm-2014.05/bin/arm-none-linux-gnueabi-g++ #cc_bcm2708=/home/wangyu/raspberry/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++ FLAGS= -std=c++11 -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-missing-field-initializers -SOURCES=main.cpp log.cpp common.cpp lib/fec.c lib/rs.c +SOURCES=main.cpp log.cpp common.cpp lib/fec.c lib/rs.c NAME=speeder TARGETS=amd64 arm mips24kc_be x86 mips24kc_le