From: Brian Aker Date: Thu, 15 Nov 2007 21:17:18 +0000 (-0800) Subject: Added test for binary append (works as an example as well!) X-Git-Tag: 0.10~9 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=9d926b6c1b6896aa345fa301666b0f98ebf1f6cf;p=awesomized%2Flibmemcached Added test for binary append (works as an example as well!) Fixed issue with bad assert in debug build Updated version --- diff --git a/ChangeLog b/ChangeLog index 84684535..904dd8a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +0.10 + * Added append binary test. + 0.9 Thu Nov 15 07:44:00 PST 2007 * fix for when no servers are definied. * different buffers are now kept for different connections to diff --git a/configure.ac b/configure.ac index 203f7e91..71a8ba53 100644 --- a/configure.ac +++ b/configure.ac @@ -6,7 +6,7 @@ MEMCACHED_LIBRARY_NAME=libmemcached #release versioning MEMCACHED_MAJOR_VERSION=0 -MEMCACHED_MINOR_VERSION=9 +MEMCACHED_MINOR_VERSION=10 MEMCACHED_MICRO_VERSION=0 #API version diff --git a/lib/memcached_storage.c b/lib/memcached_storage.c index 8d2ed8c5..af763a3e 100644 --- a/lib/memcached_storage.c +++ b/lib/memcached_storage.c @@ -56,8 +56,8 @@ static inline memcached_return memcached_send(memcached_st *ptr, char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; unsigned int server_key; - WATCHPOINT_ASSERT(value); - WATCHPOINT_ASSERT(value_length); + WATCHPOINT_ASSERT(!(value == NULL && value_length > 0)); + WATCHPOINT_ASSERT(!(value && value_length == 0)); if (key_length == 0) return MEMCACHED_NO_KEY_PROVIDED; diff --git a/tests/function.c b/tests/function.c index 9b3555e4..837f14ff 100644 --- a/tests/function.c +++ b/tests/function.c @@ -152,6 +152,51 @@ uint8_t append_test(memcached_st *memc) return 0; } +uint8_t append_binary_test(memcached_st *memc) +{ + memcached_return rc; + char *key= "numbers"; + unsigned int *store_ptr; + unsigned int store_list[] = { 23, 56, 499, 98, 32847, 0 }; + char *value; + size_t value_length; + uint16_t flags; + unsigned int x; + + rc= memcached_flush(memc, 0); + assert(rc == MEMCACHED_SUCCESS); + + rc= memcached_set(memc, + key, strlen(key), + NULL, 0, + (time_t)0, (uint16_t)0); + assert(rc == MEMCACHED_SUCCESS); + + for (x= 0; store_list[x] ; x++) + { + rc= memcached_append(memc, + key, strlen(key), + (char *)&store_list[x], sizeof(unsigned int), + (time_t)0, (uint16_t)0); + assert(rc == MEMCACHED_SUCCESS); + } + + value= memcached_get(memc, key, strlen(key), + &value_length, &flags, &rc); + assert((value_length == (sizeof(unsigned int) * x))); + assert(rc == MEMCACHED_SUCCESS); + + store_ptr= store_list; + x= 0; + while (*store_ptr) + { + assert(*store_ptr == store_list[x++]); + store_ptr++; + } + + return 0; +} + uint8_t cas_test(memcached_st *memc) { memcached_return rc; @@ -1619,6 +1664,7 @@ test_st version_1_2_3[] ={ {"append", 0, append_test }, {"prepend", 0, prepend_test }, // {"cas", 0, cas_test }, + {"append_binary", 0, append_binary_test }, {0, 0, 0} };