X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=tests%2Ffunction.c;h=015fa49ca377353dd05fb17eaf040977f1efba74;hb=948eeb667c78f158f769de8cc418e44e81048dc2;hp=d3d23e4739eecb98cb28552b8201377b9cf79d3b;hpb=1d7f999b7d38db3308a0533a83fea23987fb0178;p=awesomized%2Flibmemcached diff --git a/tests/function.c b/tests/function.c index d3d23e47..015fa49c 100644 --- a/tests/function.c +++ b/tests/function.c @@ -633,7 +633,7 @@ test_return read_through(memcached_st *memc) return 0; } -memcached_return delete_trigger(memcached_st *ptr, char *key, size_t key_length) +memcached_return delete_trigger(memcached_st *ptr, const char *key, size_t key_length) { assert(key); @@ -2003,6 +2003,33 @@ test_return user_supplied_bug15(memcached_st *memc) return 0; } +/* Check the return sizes on FLAGS to make sure it stores 32bit unsigned values correctly */ +test_return user_supplied_bug16(memcached_st *memc) +{ + uint32_t x; + memcached_return rc; + char *key= "mykey"; + char *value; + size_t length; + uint32_t flags; + + rc= memcached_set(memc, key, strlen(key), + NULL, 0, + (time_t)0, UINT32_MAX); + + assert(rc == MEMCACHED_SUCCESS); + + value= memcached_get(memc, key, strlen(key), + &length, &flags, &rc); + + assert(rc == MEMCACHED_SUCCESS); + assert(value == NULL); + assert(length == 0); + assert(flags == UINT32_MAX); + + return 0; +} + test_return result_static(memcached_st *memc) { memcached_result_st result; @@ -2463,6 +2490,42 @@ void *my_realloc(memcached_st *ptr, void *mem, const size_t size) return realloc(mem, size); } +memcached_return set_prefix(memcached_st *memc) +{ + memcached_return rc; + const char *key= "mine"; + char *value; + + /* Make sure be default none exists */ + value= memcached_callback_get(memc, MEMCACHED_CALLBACK_PREFIX_KEY, &rc); + assert(rc == MEMCACHED_FAILURE); + + /* Test a clean set */ + rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_PREFIX_KEY, (void *)key); + assert(rc == MEMCACHED_SUCCESS); + + value= memcached_callback_get(memc, MEMCACHED_CALLBACK_PREFIX_KEY, &rc); + assert(memcmp(value, key, 4) == 0); + assert(rc == MEMCACHED_SUCCESS); + + /* Test that we can turn it off */ + rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_PREFIX_KEY, NULL); + assert(rc == MEMCACHED_SUCCESS); + + value= memcached_callback_get(memc, MEMCACHED_CALLBACK_PREFIX_KEY, &rc); + assert(rc == MEMCACHED_FAILURE); + + /* Now setup for main test */ + rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_PREFIX_KEY, (void *)key); + assert(rc == MEMCACHED_SUCCESS); + + value= memcached_callback_get(memc, MEMCACHED_CALLBACK_PREFIX_KEY, &rc); + assert(rc == MEMCACHED_SUCCESS); + assert(memcmp(value, key, 4) == 0); + + return MEMCACHED_SUCCESS; +} + memcached_return set_memory_alloc(memcached_st *memc) { { @@ -2709,6 +2772,7 @@ test_st user_tests[] ={ {"user_supplied_bug13", 1, user_supplied_bug13 }, {"user_supplied_bug14", 1, user_supplied_bug14 }, {"user_supplied_bug15", 1, user_supplied_bug15 }, + {"user_supplied_bug16", 1, user_supplied_bug16 }, {0, 0, 0} }; @@ -2758,6 +2822,7 @@ collection_st collection[] ={ {"consistent", enable_consistent, 0, tests}, {"wheel", enable_wheel, 0, tests}, {"memory_allocators", set_memory_alloc, 0, tests}, + {"prefix", set_prefix, 0, tests}, // {"udp", pre_udp, 0, tests}, {"version_1_2_3", check_for_1_2_3, 0, version_1_2_3}, {"string", 0, 0, string_tests},