X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=tests%2Ffunction.c;h=514fe3c2fb8673f3977fc49053a353801e48b605;hb=fcd2bce48451825f32f05add83ced0923794d19a;hp=a6781e26031f467ad3f322a27c4214020f12798c;hpb=66fbb3939c090d99434b3b754c5760781cda1b4c;p=m6w6%2Flibmemcached diff --git a/tests/function.c b/tests/function.c index a6781e26..514fe3c2 100644 --- a/tests/function.c +++ b/tests/function.c @@ -889,6 +889,17 @@ uint8_t get_stats_keys(memcached_st *memc) return 0; } +uint8_t version_string_test(memcached_st *memc) +{ + const char *version_string; + + version_string= memcached_lib_version(); + + assert(!strcmp(version_string, LIBMEMCACHED_VERSION_STRING)); + + return 0; +} + uint8_t get_stats(memcached_st *memc) { unsigned int x; @@ -1591,6 +1602,44 @@ uint8_t user_supplied_bug11(memcached_st *memc) return 0; } +/* + Bug found where incr was not returning MEMCACHED_NOTFOUND when object did not exist. +*/ +uint8_t user_supplied_bug12(memcached_st *memc) +{ + memcached_return rc; + uint32_t flags; + size_t value_length; + char *value; + uint64_t number_value; + + value= memcached_get(memc, "autoincrement", strlen("autoincrement"), + &value_length, &flags, &rc); + assert(value == NULL); + assert(rc == MEMCACHED_NOTFOUND); + + rc= memcached_increment(memc, "autoincrement", strlen("autoincrement"), + 1, &number_value); + + assert(value == NULL); + assert(rc == MEMCACHED_NOTFOUND); + + rc= memcached_set(memc, "autoincrement", strlen("autoincrement"), "1", 1, 0, 0); + + value= memcached_get(memc, "autoincrement", strlen("autoincrement"), + &value_length, &flags, &rc); + assert(value); + assert(rc == MEMCACHED_SUCCESS); + free(value); + + rc= memcached_increment(memc, "autoincrement", strlen("autoincrement"), + 1, &number_value); + assert(number_value == 2); + assert(rc == MEMCACHED_SUCCESS); + + return 0; +} + uint8_t result_static(memcached_st *memc) { memcached_result_st result; @@ -1989,6 +2038,7 @@ memcached_return pre_hash_ketama(memcached_st *memc) return MEMCACHED_SUCCESS; } + void my_free(memcached_st *ptr, void *mem) { free(mem); @@ -2012,8 +2062,9 @@ memcached_return set_memory_alloc(memcached_st *memc) rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_MALLOC_FUNCTION, &my_malloc); assert(rc == MEMCACHED_SUCCESS); - test_ptr= (memcached_malloc_function)memcached_callback_get(memc, MEMCACHED_CALLBACK_USER_DATA, &rc); - assert(test_ptr == (memcached_malloc_function)my_malloc); + test_ptr= (memcached_malloc_function)memcached_callback_get(memc, MEMCACHED_CALLBACK_MALLOC_FUNCTION, &rc); + assert(rc == MEMCACHED_SUCCESS); + assert(test_ptr == my_malloc); } { @@ -2022,7 +2073,8 @@ memcached_return set_memory_alloc(memcached_st *memc) rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_REALLOC_FUNCTION, &my_realloc); assert(rc == MEMCACHED_SUCCESS); - test_ptr= (memcached_realloc_function)memcached_callback_get(memc, MEMCACHED_CALLBACK_USER_DATA, &rc); + test_ptr= (memcached_realloc_function)memcached_callback_get(memc, MEMCACHED_CALLBACK_REALLOC_FUNCTION, &rc); + assert(rc == MEMCACHED_SUCCESS); assert(test_ptr == my_realloc); } @@ -2032,7 +2084,8 @@ memcached_return set_memory_alloc(memcached_st *memc) rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_FREE_FUNCTION, my_free); assert(rc == MEMCACHED_SUCCESS); - test_ptr= (memcached_free_function)memcached_callback_get(memc, MEMCACHED_CALLBACK_USER_DATA, &rc); + test_ptr= (memcached_free_function)memcached_callback_get(memc, MEMCACHED_CALLBACK_FREE_FUNCTION, &rc); + assert(rc == MEMCACHED_SUCCESS); assert(test_ptr == my_free); } @@ -2174,6 +2227,7 @@ test_st tests[] ={ {"get_stats_keys", 0, get_stats_keys }, {"behavior_test", 0, get_stats_keys }, {"callback_test", 0, get_stats_keys }, + {"version_string_test", 0, version_string_test}, {0, 0, 0} }; @@ -2219,6 +2273,7 @@ test_st user_tests[] ={ {"user_supplied_bug9", 1, user_supplied_bug9 }, {"user_supplied_bug10", 1, user_supplied_bug10 }, {"user_supplied_bug11", 1, user_supplied_bug11 }, + {"user_supplied_bug12", 1, user_supplied_bug12 }, {0, 0, 0} };