added unit test

This commit is contained in:
wangyu- 2017-09-14 12:22:47 -05:00
parent b9b14f90f5
commit bc7a36858b
3 changed files with 47 additions and 1 deletions

View File

@ -46,6 +46,7 @@
#include <stdlib.h>
#include <string.h>
typedef unsigned long u_long;
/*
* compatibility stuff
*/

View File

@ -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);

View File

@ -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