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 <stdlib.h>
#include <string.h> #include <string.h>
typedef unsigned long u_long;
/* /*
* compatibility stuff * compatibility stuff
*/ */

View File

@ -923,6 +923,42 @@ int event_loop()
myexit(0); myexit(0);
return 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() void print_help()
{ {
char git_version_buf[100]={0}; char git_version_buf[100]={0};
@ -987,6 +1023,14 @@ void process_arg(int argc, char *argv[])
myexit( -1); myexit( -1);
} }
for (i = 0; i < argc; i++) 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) if(strcmp(argv[i],"-h")==0||strcmp(argv[i],"--help")==0)
{ {
@ -1232,6 +1276,7 @@ void process_arg(int argc, char *argv[])
myexit(-1); myexit(-1);
} }
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
assert(sizeof(u64_t)==8); assert(sizeof(u64_t)==8);