int main( int argc , char ** argv) { test_empty(); test_char(); test_join(); test_reverse(); test_iget_as_int(); test_iget_as_bool(); test_iget_as_double(); test_split(); test_matching(); test_unique(); test_predicate_matching(); exit(0); }
int main(int argc, char **argv){ cl_cluster *clc; cl_rv return_value; cl_object key1; cl_object key2; printf(" STARTING TESTS\n"); // initialize internal citrusleaf structures just once citrusleaf_init(); // Create a cluster with a particular starting host printf(" STARTING CLUSTER CREATION TEST .... \n"); clc = citrusleaf_cluster_create(); if (!clc){ printf("TEST FAILED: Could not create cluster object"); return(-1); } return_value = citrusleaf_cluster_add_host(clc, host, 3000, 1000); if( return_value != CITRUSLEAF_OK ){ printf("TEST FAILED - cannot connect to host\n"); return -1; } // XXX - need to do some info calls with a bigger cluster! printf(" DONE\n"); // set up the key. Create a stack object, set its value to a string cl_object key_obj; citrusleaf_object_init_str(&key_obj, myKey); // set up a specific bins to fetch // the response will be in this value cl_bin values[3]; strcpy( &values[0].bin_name[0], bin1 ); citrusleaf_object_init_str( &values[0].object, strData); strcpy( &values[1].bin_name[0], bin2); citrusleaf_object_init_int( &values[1].object, intData ); strcpy( &values[2].bin_name[0], bin3); citrusleaf_object_init_blob( &values[2].object, blobData, strlen(blobData)+1); printf("params to put are clc %p, ns %s, set %s, key %p, values %p\n", clc, ns, myset, &key_obj, values); return_value = citrusleaf_put(clc, ns, myset, &key_obj, values, 3, NULL); if( return_value != CITRUSLEAF_OK ){ printf(" TEST FAILS - INITIAL PUT FAILS, value is %d\n", return_value); return(-1); } citrusleaf_object_init(&values[0].object); citrusleaf_object_init(&values[1].object); citrusleaf_object_init(&values[2].object); return_value = citrusleaf_get(clc, ns, myset, &key_obj, values, 3, 0, NULL); switch (return_value) { case CITRUSLEAF_OK: if (values[0].object.type != CL_STR) { printf(" TEST FAILS - value has unexpected type %d\n",values[0].object.type); goto cleanup; } else if( strcmp(values[0].object.u.str, strData) ){ printf("TEST FAILS - WRITE DOES NOT RETURN WHAT WAS WRITTEN: %s, %s\n", values[0].object.u.str, strData); goto cleanup; } if (values[1].object.type != CL_INT) { printf(" TEST FAILS - value has unexpected type %d\n",values[1].object.type); goto cleanup; } else if( values[1].object.u.i64 != intData){ printf("TEST FAILS - WRITE DOES NOT RETURN WHAT WAS WRITTEN, %lu, %lu\n", values[1].object.u.i64, intData); goto cleanup; } if( values[2].object.type != CL_BLOB) { printf(" TEST FAILS - value has unexpected type %d\n",values[1].object.type); goto cleanup; }else if( strcmp(values[2].object.u.blob, blobData) ){ printf(" TEST FAILS - WRITE DOES NOT RETURN CORRECT BLOB DATA\n"); goto cleanup; } break; case CITRUSLEAF_FAIL_NOTFOUND: printf(" TEST FAILS - citrusleaf says that key does not exist\n"); goto cleanup; break; case CITRUSLEAF_FAIL_CLIENT: printf(" TEST FAILS - citrusleaf client error: local error\n"); goto cleanup; break; case CITRUSLEAF_FAIL_PARAMETER: printf(" TEST FAILS - citrusleaf - bad parameter passed in \n"); goto cleanup; break; case CITRUSLEAF_FAIL_TIMEOUT: printf(" TEST FAILS - citrusleaf - timeout on get\n"); goto cleanup; break; case CITRUSLEAF_FAIL_UNKNOWN: printf(" TEST _FAILS - citrusleaf - unknown server error\n"); goto cleanup; break; default : printf(" TEST_FAILS - error %d\n", return_value); goto cleanup; } // clean up the retrieved objects citrusleaf_object_free(&values[0].object); citrusleaf_object_free(&values[1].object); if( test_getall(clc) ) goto cleanup; if( read_mod_write(clc) ) goto cleanup; if( test_unique(clc) ) goto cleanup; if( test_operate(clc) ) goto cleanup; if( test_batch(clc) ) goto cleanup; printf("TEST SUCCESSFUL!\n"); cleanup: citrusleaf_object_init_str(&key1,myKey); citrusleaf_object_init_str(&key2,myKey2); citrusleaf_delete(clc, ns, myset, &key1, NULL); citrusleaf_delete(clc, ns, myset, &key2, NULL); // Clean up the cluster object citrusleaf_cluster_destroy(clc); // Clean up the unit citrusleaf_shutdown(); }