projects
/
awesomized
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
Additional test to test for failure on get replication.
[awesomized/libmemcached]
/
tests
/
hash_plus.cc
diff --git
a/tests/hash_plus.cc
b/tests/hash_plus.cc
index c148d3effd10528ac8cf427ef6bc4447a02df93d..20cf79db0f4e0a7fe1535decf03ac38e3106f84d 100644
(file)
--- a/
tests/hash_plus.cc
+++ b/
tests/hash_plus.cc
@@
-1,13
+1,16
@@
/*
C++ to libhashkit
*/
/*
C++ to libhashkit
*/
+
+#include <config.h>
+
#include <libtest/test.h>
#include <libtest/test.h>
-#include <
stdio.h
>
-#include <
stdlib.h
>
-#include <
string.h
>
+#include <
cstdio
>
+#include <
cstdlib
>
+#include <
cstring
>
-#include <libhashkit/hashkit.h>
+#include <libhashkit/hashkit.h
pp
>
#include "hash_results.h"
#include "hash_results.h"
@@
-69,7
+72,7
@@
static test_return_t digest_test(void *obj)
return TEST_SUCCESS;
}
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[]= {
{
Hashkit hashk;
hashkit_hash_algorithm_t algo_list[]= {
@@
-84,21
+87,15
@@
static test_return_t set_function_test(void *obj)
HASHKIT_HASH_JENKINS,
HASHKIT_HASH_MAX
};
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);
test_true(rc == HASHKIT_SUCCESS);
+ uint32_t *list;
switch (*algo)
{
case HASHKIT_HASH_DEFAULT:
switch (*algo)
{
case HASHKIT_HASH_DEFAULT:
@@
-123,9
+120,18
@@
static test_return_t set_function_test(void *obj)
list= fnv1a_32_values;
break;
case HASHKIT_HASH_HSIEH:
list= fnv1a_32_values;
break;
case HASHKIT_HASH_HSIEH:
+#ifndef HAVE_HSIEH_HASH
+ continue;
+#endif
list= hsieh_values;
break;
case HASHKIT_HASH_MURMUR:
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:
list= murmur_values;
break;
case HASHKIT_HASH_JENKINS:
@@
-139,12
+145,16
@@
static test_return_t set_function_test(void *obj)
}
// Now we make sure we did set the hash correctly.
}
// 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));
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);
}
}
}
}
@@
-158,7
+168,7
@@
static test_return_t set_distribution_function_test(void *obj)
(void)obj;
rc= hashk.set_distribution_function(HASHKIT_HASH_CUSTOM);
(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);
rc= hashk.set_distribution_function(HASHKIT_HASH_JENKINS);
test_true(rc == HASHKIT_SUCCESS);