From: Date: Fri, 21 Mar 2008 16:43:33 +0000 (-0700) Subject: Extended server_sort_test() test. X-Git-Tag: 0.20~1^2~43 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=120172bf400e556cf60d10488f42f2292f478838;p=awesomized%2Flibmemcached Extended server_sort_test() test. Also moved around double define. --- diff --git a/libmemcached/memcached.h b/libmemcached/memcached.h index 2e7cf6db..2df0b7ae 100644 --- a/libmemcached/memcached.h +++ b/libmemcached/memcached.h @@ -30,15 +30,6 @@ extern "C" { /* These are Private and should not be used by applications */ #define MEMCACHED_VERSION_STRING_LENGTH 12 -/* Public defines */ -#define MEMCACHED_DEFAULT_PORT 11211 -#define MEMCACHED_MAX_KEY 251 /* We add one to have it null terminated */ -#define MEMCACHED_MAX_BUFFER 8196 -#define MEMCACHED_MAX_HOST_LENGTH 64 -#define MEMCACHED_WHEEL_SIZE 1024 -#define MEMCACHED_STRIDE 4 -#define MEMCACHED_DEFAULT_TIMEOUT INT32_MAX - /* string value */ #define LIBMEMCACHED_VERSION_STRING "0.19" diff --git a/tests/function.c b/tests/function.c index 74f9a354..19c104df 100644 --- a/tests/function.c +++ b/tests/function.c @@ -59,26 +59,42 @@ uint8_t server_list_null_test(memcached_st *ptr) return 0; } +#define TEST_PORT_COUNT 7 +uint32_t test_ports[TEST_PORT_COUNT]; + +memcached_return server_display_function(memcached_st *ptr, memcached_server_st *server, void *context) +{ + /* Do Nothing */ + uint32_t *bigger= (uint32_t *)context; + assert(*bigger <= server->port); + + return MEMCACHED_SUCCESS; +} + uint8_t server_sort_test(memcached_st *ptr) { - memcached_server_st *server_list; + uint8_t x; + uint32_t bigger= 0; /* Prime the value for the assert in server_display_function */ memcached_return rc; + memcached_server_function callbacks[1]; + memcached_st *local_memc; - memcached_behavior_set(ptr, MEMCACHED_BEHAVIOR_SORT_HOSTS, 1); - - server_list= memcached_server_list_append(NULL, "arg", 0, &rc); - assert(server_list); + local_memc= memcached_create(NULL); + assert(local_memc); + memcached_behavior_set(local_memc, MEMCACHED_BEHAVIOR_SORT_HOSTS, 1); - server_list= memcached_server_list_append(server_list, "localhost", 0, &rc); - assert(server_list); + for (x= 0; x < TEST_PORT_COUNT; x++) + { + test_ports[x]= random() % 64000; + rc= memcached_server_add(local_memc, "localhost", test_ports[x]); + assert(rc == MEMCACHED_SUCCESS); + } - server_list= memcached_server_list_append(server_list, "c", 0, &rc); - assert(server_list); + callbacks[0]= server_display_function; + memcached_server_cursor(local_memc, callbacks, (void *)&bigger, 1); - server_list= memcached_server_list_append(server_list, "abba", 0, &rc); - assert(server_list); - free(server_list); + memcached_free(local_memc); return 0; }