X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;ds=sidebyside;f=tests%2Fhash_plus.cc;h=20cf79db0f4e0a7fe1535decf03ac38e3106f84d;hb=7551ea615b5f6cfaa390f7d24dca2fa388943ddb;hp=30e14106fa74e931e375e4e6ef01f2883b2e5920;hpb=c15e27789bf0ba95ae05e70628a1eb39016159c9;p=awesomized%2Flibmemcached diff --git a/tests/hash_plus.cc b/tests/hash_plus.cc index 30e14106..20cf79db 100644 --- a/tests/hash_plus.cc +++ b/tests/hash_plus.cc @@ -1,12 +1,16 @@ /* C++ to libhashkit */ -#include "test.h" -#include -#include -#include -#include +#include + +#include + +#include +#include +#include + +#include #include "hash_results.h" @@ -14,6 +18,7 @@ static test_return_t exists_test(void *obj) { Hashkit hashk; (void)obj; + (void)hashk; return TEST_SUCCESS; } @@ -67,7 +72,7 @@ static test_return_t digest_test(void *obj) return TEST_SUCCESS; } -static test_return_t set_function_test(void *obj) +static test_return_t set_function_test(void *) { Hashkit hashk; hashkit_hash_algorithm_t algo_list[]= { @@ -82,21 +87,15 @@ static test_return_t set_function_test(void *obj) HASHKIT_HASH_JENKINS, HASHKIT_HASH_MAX }; - hashkit_hash_algorithm_t *algo; - (void)obj; - for (algo= algo_list; *algo != HASHKIT_HASH_MAX; algo++) + for (hashkit_hash_algorithm_t *algo= algo_list; *algo != HASHKIT_HASH_MAX; algo++) { - hashkit_return_t rc; - uint32_t x; - const char **ptr; - uint32_t *list; - - rc= hashk.set_function(*algo); + hashkit_return_t rc= hashk.set_function(*algo); test_true(rc == HASHKIT_SUCCESS); + uint32_t *list; switch (*algo) { case HASHKIT_HASH_DEFAULT: @@ -121,9 +120,18 @@ static test_return_t set_function_test(void *obj) list= fnv1a_32_values; break; case HASHKIT_HASH_HSIEH: +#ifndef HAVE_HSIEH_HASH + continue; +#endif list= hsieh_values; break; case HASHKIT_HASH_MURMUR: +#ifdef WORDS_BIGENDIAN + continue; +#endif +#ifndef HAVE_MURMUR_HASH + continue; +#endif list= murmur_values; break; case HASHKIT_HASH_JENKINS: @@ -137,12 +145,16 @@ static test_return_t set_function_test(void *obj) } // Now we make sure we did set the hash correctly. + uint32_t x; + const char **ptr; for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) { uint32_t hash_val; hash_val= hashk.digest(*ptr, strlen(*ptr)); - test_true(list[x] == hash_val); + char buffer[1024]; + snprintf(buffer, sizeof(buffer), "%lu %lus %s", (unsigned long)list[x], (unsigned long)hash_val, libhashkit_string_hash(*algo)); + test_true_got(list[x] == hash_val, buffer); } } @@ -156,7 +168,7 @@ static test_return_t set_distribution_function_test(void *obj) (void)obj; rc= hashk.set_distribution_function(HASHKIT_HASH_CUSTOM); - test_true(rc == HASHKIT_FAILURE); + test_true_got(rc == HASHKIT_FAILURE or rc == HASHKIT_INVALID_ARGUMENT, hashkit_strerror(NULL, rc)); rc= hashk.set_distribution_function(HASHKIT_HASH_JENKINS); test_true(rc == HASHKIT_SUCCESS);