Diff for /libaitio/example/Attic/test_vars.c between versions 1.3 and 1.5.2.1

version 1.3, 2012/07/22 20:39:45 version 1.5.2.1, 2012/09/17 13:55:33
Line 14  cmpfunc(const void *a, const void *b) Line 14  cmpfunc(const void *a, const void *b)
         return strcmp(AIT_GET_STR(*(ait_val_t**) a), AIT_GET_STR(*(ait_val_t**) b));          return strcmp(AIT_GET_STR(*(ait_val_t**) a), AIT_GET_STR(*(ait_val_t**) b));
 }  }
   
   static void
   makevars()
   {
           ait_val_t *v;
   
           v = io_makeVar(empty);
           printf("Variable is empty? %d\n", AIT_ISEMPTY(v));
           io_freeVar(&v);
           v = io_makeVar(ptr, 0x12345678, 42);
           printf("Variable is ptr=%p len=%u\n", AIT_GET_PTR(v), AIT_LEN(v));
           io_freeVar(&v);
           v = io_makeVar(data, "TEST DATA !!!", 14);
           printf("Variable is data=%s len=%u\n", AIT_GET_DATA(v), AIT_LEN(v));
           io_freeVar(&v);
           v = io_makeVar(buffer, "TEST Buffer !!!", 16);
           printf("Variable is buf=%s len=%u\n", AIT_GET_BUF(v), AIT_LEN(v));
           io_freeVar(&v);
           v = io_makeVar(string, "TEST String ...");
           printf("Variable is str=%s len=%u\n", AIT_GET_STR(v), AIT_LEN(v));
           io_freeVar(&v);
           v = io_makeVar(blob, 1234, 10000);
           printf("Variable is blob=%u len=%u\n", AIT_GET_BLOB(v), AIT_LEN(v));
           io_freeVar(&v);
           v = io_makeVar(f32, 1.0123);
           printf("Variable is f32=%f\n", AIT_GET_F32(v));
           io_freeVar(&v);
           v = io_makeVar(f64, 0.00123321);
           printf("Variable is f64=%f\n", AIT_GET_F64(v));
           io_freeVar(&v);
           v = io_makeVar(u8, 1);
           printf("Variable is u8=%hhu\n", AIT_GET_U8(v));
           io_freeVar(&v);
           v = io_makeVar(u16, 32000);
           printf("Variable is u16=%hu\n", AIT_GET_U16(v));
           io_freeVar(&v);
           v = io_makeVar(u32, 0xfedecaa0);
           printf("Variable is u32=%u\n", AIT_GET_U32(v));
           io_freeVar(&v);
           v = io_makeVar(u64, 0xffeedccfedecaa01LL);
           printf("Variable is u64=%llu\n", AIT_GET_U64(v));
           io_freeVar(&v);
           v = io_makeVar(i8, -1);
           printf("Variable is i8=%hhd\n", AIT_GET_I8(v));
           io_freeVar(&v);
           v = io_makeVar(i16, -28888);
           printf("Variable is i16=%hd\n", AIT_GET_I16(v));
           io_freeVar(&v);
           v = io_makeVar(i32, -23424234);
           printf("Variable is i32=%d\n", AIT_GET_I32(v));
           io_freeVar(&v);
           v = io_makeVar(i64, -123234200000342LL);
           printf("Variable is i64=%lld\n", AIT_GET_I64(v));
           io_freeVar(&v);
   }
   
   static void
   testcmp()
   {
           ait_val_t a, b;
   
           AIT_SET_STR(&a, "OHO boho");
           AIT_SET_STR(&b, "OHO boho");
           printf("Test equal strings %d\n", io_cmpVar(&a, &b));
           AIT_FREE_VAL(&b);
           AIT_SET_STR(&b, "OHO b0ho");
           printf("Test not equal strings %d\n", io_cmpVar(&a, &b));
           AIT_FREE_VAL(&b);
           AIT_SET_STR(&b, "OHO b0ho different");
           printf("Test not equal in length %d\n", io_cmpVar(&a, &b));
           AIT_FREE_VAL(&b);
           AIT_SET_BUF(&b, "OHO", 4);
           printf("Test not equal in type %d\n", io_cmpVar(&a, &b));
           AIT_FREE_VAL(&b);
           AIT_FREE_VAL(&a);
           AIT_SET_I16(&a, 5);
           AIT_SET_I16(&b, 5);
           printf("Test equal num %d\n", io_cmpVar(&a, &b));
           AIT_SET_I16(&b, 2);
           printf("Test not equal num %d\n", io_cmpVar(&a, &b));
           AIT_SET_U8(&b, 9);
           printf("Test not equal in type %d\n", io_cmpVar(&a, &b));
   }
   
 int  int
 main(int argc, char **argv)  main(int argc, char **argv)
 {  {
Line 21  main(int argc, char **argv) Line 104  main(int argc, char **argv)
         ait_val_t *v;          ait_val_t *v;
         register int i;          register int i;
   
           if (argc < 2) {
                   makevars();
                   testcmp();
                   return 0;
           }
   
         arr = io_allocVars((argc - 1 ) / 2);          arr = io_allocVars((argc - 1 ) / 2);
         if (!arr) {          if (!arr) {
                 printf("Error:: #%d - %s\n", io_GetErrno(), io_GetError());                  printf("Error:: #%d - %s\n", io_GetErrno(), io_GetError());
Line 43  main(int argc, char **argv) Line 132  main(int argc, char **argv)
         printf("search for key=0 %s\n", v ? AIT_GET_LIKE(v, char*) : "");          printf("search for key=0 %s\n", v ? AIT_GET_LIKE(v, char*) : "");
         v = io_findKeyVars(arr, 99);          v = io_findKeyVars(arr, 99);
         printf("search for key=99 %s\n", v ? AIT_GET_LIKE(v, char*) : "");          printf("search for key=99 %s\n", v ? AIT_GET_LIKE(v, char*) : "");
   
           io_hashKeyVars(arr);
   
           v = io_getVars(&arr, io_arraySize(arr));
           AIT_SET_STR(v, "mauhahahaha ohoho and bottle of rum!");
           io_hashVar(v, "Baba Yaga #1");
   
           v = io_findKeyHash(arr, "Baba Yaga #1");
           printf("search for hash='Baba Yaga #1' %s\n", v ? AIT_GET_LIKE(v, char*) : "");
   
         printf("Before sorting::\n");          printf("Before sorting::\n");
         for (i = 0; i < io_arraySize(arr); i++)          for (i = 0; i < io_arraySize(arr); i++)

Removed from v.1.3  
changed lines
  Added in v.1.5.2.1


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>