X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=tests%2Fplus.cpp;h=be6cde5098cfad6d1cd2e39a4799cfd7c3dbaf37;hb=a246ac50a88e4af750fd2dd209eff94dcadf72d2;hp=6ffd090f7822ea0b1ee61af938fa58fa182f6e3c;hpb=604540c15315c6ed876082529f639697ba3eceab;p=awesomized%2Flibmemcached diff --git a/tests/plus.cpp b/tests/plus.cpp index 6ffd090f..be6cde50 100644 --- a/tests/plus.cpp +++ b/tests/plus.cpp @@ -29,11 +29,9 @@ extern "C" { test_return_t mget_result_function(memcached_st *memc); test_return_t basic_behavior(memcached_st *memc); test_return_t mget_test(memcached_st *memc); - memcached_return callback_counter(memcached_st *, - memcached_result_st *, - void *context); - void *world_create(void); - void world_destroy(void *p); + memcached_return_t callback_counter(memcached_st *, + memcached_result_st *, + void *context); } static void populate_vector(vector &vec, const string &str) @@ -65,7 +63,7 @@ test_return_t basic_test(memcached_st *memc) assert((memcmp(&test_value[0], &value[0], test_value.size()) == 0)); - /* + /* * Simple test of the exceptions here...this should throw an exception * saying that the key is empty. */ @@ -109,7 +107,7 @@ test_return_t increment_test(memcached_st *memc) int_inc_value= uint64_t(atol(inc_value.c_str())); int_ret_value= uint64_t(atol(ret_string.c_str())); - assert(int_ret_value == int_inc_value); + assert(int_ret_value == int_inc_value); rc= mcach.increment(key, 1, &int_ret_value); assert(rc == true); @@ -152,8 +150,8 @@ test_return_t basic_master_key_test(memcached_st *memc) } /* Count the results */ -memcached_return callback_counter(memcached_st *, - memcached_result_st *, +memcached_return_t callback_counter(memcached_st *, + memcached_result_st *, void *context) { unsigned int *counter= static_cast(context); @@ -187,7 +185,7 @@ test_return_t mget_result_function(memcached_st *memc) values.push_back(&val2); values.push_back(&val3); unsigned int counter; - memcached_execute_function callbacks[1]; + memcached_execute_fn callbacks[1]; /* We need to empty the server before we continue the test */ rc= mc.flush(0); @@ -199,7 +197,7 @@ test_return_t mget_result_function(memcached_st *memc) callbacks[0]= &callback_counter; counter= 0; - rc= mc.fetchExecute(callbacks, static_cast(&counter), 1); + rc= mc.fetchExecute(callbacks, static_cast(&counter), 1); assert(counter == 3); @@ -210,7 +208,7 @@ test_return_t mget_test(memcached_st *memc) { Memcache mc(memc); bool rc; - memcached_return mc_rc; + memcached_return_t mc_rc; vector keys; vector< vector *> values; keys.reserve(3); @@ -274,12 +272,18 @@ test_return_t basic_behavior(memcached_st *memc) } test_st tests[] ={ - { "basic", 0, basic_test }, - { "basic_master_key", 0, basic_master_key_test }, - { "increment_test", 0, increment_test }, - { "mget", 1, mget_test }, - { "mget_result_function", 1, mget_result_function }, - { "basic_behavior", 0, basic_behavior }, + { "basic", 0, + reinterpret_cast(basic_test) }, + { "basic_master_key", 0, + reinterpret_cast(basic_master_key_test) }, + { "increment_test", 0, + reinterpret_cast(increment_test) }, + { "mget", 1, + reinterpret_cast(mget_test) }, + { "mget_result_function", 1, + reinterpret_cast(mget_result_function) }, + { "basic_behavior", 0, + reinterpret_cast(basic_behavior) }, {0, 0, 0} }; @@ -288,35 +292,19 @@ collection_st collection[] ={ {0, 0, 0, 0} }; -#define SERVERS_TO_CREATE 1 +#define SERVERS_TO_CREATE 5 -extern "C" void *world_create(void) -{ - server_startup_st *construct; - - construct= (server_startup_st *)malloc(sizeof(server_startup_st)); - memset(construct, 0, sizeof(server_startup_st)); - - construct->count= SERVERS_TO_CREATE; - server_startup(construct); - - return construct; -} - -void world_destroy(void *p) -{ - server_startup_st *construct= static_cast(p); - memcached_server_st *servers= - static_cast(construct->servers); - memcached_server_list_free(servers); - - server_shutdown(construct); - free(construct); -} +#include "libmemcached_world.h" void get_world(world_st *world) { world->collections= collection; - world->create= world_create; - world->destroy= world_destroy; + world->collection_startup= reinterpret_cast(world_collection_startup); + world->flush= reinterpret_cast(world_flush); + world->pre_run= reinterpret_cast(world_pre_run); + world->create= reinterpret_cast(world_create); + world->post_run= reinterpret_cast(world_post_run); + world->on_error= reinterpret_cast(world_on_error); + world->destroy= reinterpret_cast(world_destroy); + world->runner= &defualt_libmemcached_runner; }