From: Brian Aker Date: Fri, 7 Oct 2011 19:28:07 +0000 (-0700) Subject: Merge in additional compiler/test cleanups. X-Git-Tag: 1.0.2~8^2~1^2~1 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=04b45ce37004a39db2e033287cc927b727f2820f;p=m6w6%2Flibmemcached Merge in additional compiler/test cleanups. --- diff --git a/tests/mem_functions.cc b/tests/mem_functions.cc index 966d8b30..ac88490b 100644 --- a/tests/mem_functions.cc +++ b/tests/mem_functions.cc @@ -2009,16 +2009,13 @@ static test_return_t behavior_test(memcached_st *memc) memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, 1); test_compare(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY)); - uint32_t set= MEMCACHED_HASH_MD5; - memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, set); - test_compare(MEMCACHED_HASH_MD5, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_HASH)); - - set= 0; + memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, MEMCACHED_HASH_MD5); + test_compare(uint64_t(MEMCACHED_HASH_MD5), memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_HASH)); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0); test_zero(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_NO_BLOCK)); - memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, set); + memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, 0); test_zero(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY)); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, MEMCACHED_HASH_DEFAULT); @@ -2042,11 +2039,8 @@ static test_return_t behavior_test(memcached_st *memc) static test_return_t MEMCACHED_BEHAVIOR_CORK_test(memcached_st *memc) { - memcached_return_t rc; - bool set= true; - - rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_CORK, set); - test_true(rc == MEMCACHED_DEPRECATED); + test_compare(MEMCACHED_DEPRECATED, + memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_CORK, true)); // Platform dependent #if 0 @@ -2060,22 +2054,18 @@ static test_return_t MEMCACHED_BEHAVIOR_CORK_test(memcached_st *memc) static test_return_t MEMCACHED_BEHAVIOR_TCP_KEEPALIVE_test(memcached_st *memc) { - memcached_return_t rc; - bool set= true; - bool value; - - rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_KEEPALIVE, set); + memcached_return_t rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_KEEPALIVE, true); test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_NOT_SUPPORTED); - value= (bool)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_TCP_KEEPALIVE); + bool value= (bool)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_TCP_KEEPALIVE); - if (rc == MEMCACHED_SUCCESS) + if (memcached_success(rc)) { - test_true((bool)value == set); + test_true(value); } else { - test_false((bool)value == set); + test_false(value); } return TEST_SUCCESS; @@ -2084,22 +2074,18 @@ static test_return_t MEMCACHED_BEHAVIOR_TCP_KEEPALIVE_test(memcached_st *memc) static test_return_t MEMCACHED_BEHAVIOR_TCP_KEEPIDLE_test(memcached_st *memc) { - memcached_return_t rc; - bool set= true; - bool value; - - rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_KEEPIDLE, set); + memcached_return_t rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_KEEPIDLE, true); test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_NOT_SUPPORTED); - value= (bool)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_TCP_KEEPIDLE); + bool value= (bool)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_TCP_KEEPIDLE); - if (rc == MEMCACHED_SUCCESS) + if (memcached_success(rc)) { - test_true((bool)value == set); + test_true(value); } else { - test_false((bool)value == set); + test_false(value); } return TEST_SUCCESS; @@ -2145,11 +2131,10 @@ static test_return_t user_supplied_bug1(memcached_st *memc) /* We just keep looking at the same values over and over */ srandom(10); - unsigned int setter= 1; test_compare(MEMCACHED_SUCCESS, - memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, setter)); + memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, true)); test_compare(MEMCACHED_SUCCESS, - memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, setter)); + memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, true)); /* add key */ @@ -2180,19 +2165,15 @@ static test_return_t user_supplied_bug1(memcached_st *memc) /* Test case provided by Cal Haldenbrand */ static test_return_t user_supplied_bug2(memcached_st *memc) { - unsigned int setter= 1; - test_compare(MEMCACHED_SUCCESS, - memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, setter)); + memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, true)); test_compare(MEMCACHED_SUCCESS, - memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, setter)); + memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, true)); #ifdef NOT_YET - setter = 20 * 1024576; - memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE, setter); - setter = 20 * 1024576; - memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE, setter); + test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE, 20 * 1024576)); + test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE, 20 * 1024576)); getter = memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE); getter = memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE); @@ -2240,10 +2221,8 @@ static test_return_t user_supplied_bug3(memcached_st *memc) test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, 1)); #ifdef NOT_YET - setter = 20 * 1024576; - memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE, setter); - setter = 20 * 1024576; - memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE, setter); + memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE, 20 * 1024576); + memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE, 20 * 1024576); getter = memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE); getter = memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE); #endif @@ -2499,7 +2478,9 @@ static test_return_t user_supplied_bug7(memcached_st *memc) char *insert_data= new (std::nothrow) char[VALUE_SIZE_BUG5]; for (unsigned int x= 0; x < VALUE_SIZE_BUG5; x++) + { insert_data[x]= (signed char)rand(); + } memcached_flush(memc, 0); @@ -2512,11 +2493,11 @@ static test_return_t user_supplied_bug7(memcached_st *memc) flags= 0; value= memcached_get(memc, keys, key_length, &value_length, &flags, &rc); - test_true(flags == 245); + test_compare(245U, flags); test_true(value); free(value); - rc= memcached_mget(memc, &keys, &key_length, 1); + test_compare(MEMCACHED_SUCCESS, memcached_mget(memc, &keys, &key_length, 1)); flags= 0; value= memcached_fetch(memc, return_key, &return_key_length,