X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=tests%2Fhashkit_functions.cc;h=59c53809c1e065360417643087cf20c697bceb0d;hb=033a3a1829e8a1e0d170f748f6b7824e25ec45f4;hp=2d664e7c64e3fb629c07608b15547ee9473b2659;hpb=65580ac6cb193fd73e12117c1ba492c57c3d0be4;p=awesomized%2Flibmemcached diff --git a/tests/hashkit_functions.cc b/tests/hashkit_functions.cc index 2d664e7c..59c53809 100644 --- a/tests/hashkit_functions.cc +++ b/tests/hashkit_functions.cc @@ -35,19 +35,19 @@ * */ -#include +#include #include using namespace libtest; -#include #include #include #include -#include +#include +#include -#include "hash_results.h" +#include "tests/hash_results.h" static hashkit_st global_hashk; @@ -262,6 +262,27 @@ static test_return_t hsieh_run (hashkit_st *) return TEST_SUCCESS; } +static test_return_t murmur3_TEST(hashkit_st *) +{ + test_skip(true, libhashkit_has_algorithm(HASHKIT_HASH_MURMUR3)); + +#ifdef WORDS_BIGENDIAN + (void)murmur3_values; + return TEST_SKIPPED; +#else + uint32_t x; + const char **ptr; + + for (ptr= list_to_hash, x= 0; *ptr; ptr++, x++) + { + test_compare(murmur3_values[x], + libhashkit_murmur3(*ptr, strlen(*ptr))); + } + + return TEST_SUCCESS; +#endif +} + static test_return_t murmur_run (hashkit_st *) { test_skip(true, libhashkit_has_algorithm(HASHKIT_HASH_MURMUR)); @@ -326,7 +347,12 @@ static test_return_t hashkit_set_function_test(hashkit_st *hashk) const char **ptr; uint32_t *list; - test_skip(true, libhashkit_has_algorithm(static_cast(algo))); + if (HASHKIT_HASH_CUSTOM == algo) { + continue; + } + if (!libhashkit_has_algorithm(static_cast(algo))) { + continue; + } hashkit_return_t rc= hashkit_set_function(hashk, static_cast(algo)); @@ -370,6 +396,10 @@ static test_return_t hashkit_set_function_test(hashkit_st *hashk) list= murmur_values; break; + case HASHKIT_HASH_MURMUR3: + list= murmur3_values; + break; + case HASHKIT_HASH_JENKINS: list= jenkins_values; break; @@ -392,7 +422,7 @@ static test_return_t hashkit_set_function_test(hashkit_st *hashk) } else { - return TEST_FAILURE; + test_fail("Unknown algorithm"); } } @@ -452,7 +482,7 @@ static test_return_t hashkit_get_function_test(hashkit_st *hashk) for (int algo= int(HASHKIT_HASH_DEFAULT); algo < int(HASHKIT_HASH_MAX); algo++) { - if (HASHKIT_HASH_CUSTOM) + if (HASHKIT_HASH_CUSTOM == algo) { continue; } @@ -509,6 +539,7 @@ test_st hash_tests[] ={ {"fnv1a_32", 0, (test_callback_fn*)fnv1a_32_run }, {"hsieh", 0, (test_callback_fn*)hsieh_run }, {"murmur", 0, (test_callback_fn*)murmur_run }, + {"murmur3", 0, (test_callback_fn*)murmur3_TEST }, {"jenkis", 0, (test_callback_fn*)jenkins_run }, {0, 0, (test_callback_fn*)0} }; @@ -562,9 +593,9 @@ static bool world_destroy(void *object) return TEST_SUCCESS; } -void get_world(Framework *world) +void get_world(libtest::Framework* world) { - world->collections= collection; - world->_create= world_create; - world->_destroy= world_destroy; + world->collections(collection); + world->create(world_create); + world->destroy(world_destroy); }