Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
eabcbb62f3
  1. 25
      iguana/tests/json_extracta.c
  2. 25
      iguana/tests/json_extractd.c
  3. 25
      iguana/tests/json_extracti.c
  4. 3
      iguana/tests/make_jsoncmp

25
iguana/tests/json_extracta.c

@ -0,0 +1,25 @@
#include <stdio.h>
#include <stdint.h>
#include "../../includes/cJSON.h"
#include "../../crypto777/OS_portable.h"
int32_t main(int32_t argc,char **argv)
{
cJSON *filejson; char *fname,*filestr,*field; long filesize; int32_t n;
if ( argc > 2 )
{
fname = argv[1];
field = argv[2];
if ( (filestr= OS_filestr(&filesize,fname)) != 0 )
{
if ( (filejson= cJSON_Parse(filestr)) != 0 )
{
if ( jarray(&n,filejson,field) != 0 )
printf("%s\n",jprint(jobj(filejson,field),0));
free_json(filejson);
} else fprintf(stderr,"cant parse.(%s)\n",filestr);
free(filestr);
} else fprintf(stderr,"cant load (%s)\n",fname);
} else fprintf(stderr,"argc.%d fname.(%s) error\n",argc,argv[1]);
}

25
iguana/tests/json_extractd.c

@ -0,0 +1,25 @@
#include <stdio.h>
#include <stdint.h>
#include "../../includes/cJSON.h"
#include "../../crypto777/OS_portable.h"
int32_t main(int32_t argc,char **argv)
{
cJSON *filejson; char *fname,*filestr,*field; long filesize;
if ( argc > 2 )
{
fname = argv[1];
field = argv[2];
if ( (filestr= OS_filestr(&filesize,fname)) != 0 )
{
if ( (filejson= cJSON_Parse(filestr)) != 0 )
{
if ( jobj(filejson,field) != 0 )
printf("%.8f\n",jdouble(filejson,field));
free_json(filejson);
} else fprintf(stderr,"cant parse.(%s)\n",filestr);
free(filestr);
} else fprintf(stderr,"cant load (%s)\n",fname);
} else fprintf(stderr,"argc.%d fname.(%s) error\n",argc,argv[1]);
}

25
iguana/tests/json_extracti.c

@ -0,0 +1,25 @@
#include <stdio.h>
#include <stdint.h>
#include "../../includes/cJSON.h"
#include "../../crypto777/OS_portable.h"
int32_t main(int32_t argc,char **argv)
{
cJSON *filejson; char *fname,*filestr,*field; long filesize;
if ( argc > 2 )
{
fname = argv[1];
field = argv[2];
if ( (filestr= OS_filestr(&filesize,fname)) != 0 )
{
if ( (filejson= cJSON_Parse(filestr)) != 0 )
{
if ( jobj(filejson,field) != 0 )
printf("%d\n",jint(filejson,field));
free_json(filejson);
} else fprintf(stderr,"cant parse.(%s)\n",filestr);
free(filestr);
} else fprintf(stderr,"cant load (%s)\n",fname);
} else fprintf(stderr,"argc.%d fname.(%s) error\n",argc,argv[1]);
}

3
iguana/tests/make_jsoncmp

@ -1,2 +1,5 @@
gcc -o jsoncmp jsoncmp.c ../../agents/libcrypto777.a -pthread -lm
gcc -o json_extract json_extract.c ../../agents/libcrypto777.a -pthread -lm
gcc -o json_extracti json_extracti.c ../../agents/libcrypto777.a -pthread -lm
gcc -o json_extractd json_extractd.c ../../agents/libcrypto777.a -pthread -lm
gcc -o json_extracta json_extracta.c ../../agents/libcrypto777.a -pthread -lm

Loading…
Cancel
Save