Skip to content

Commit 329e1ab

Browse files
authored
Merge pull request #641 from twitter/tests-compilation-misc
Add miscellaneous tests, fix compilation warnings
2 parents f46d1b8 + cfeb446 commit 329e1ab

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ AC_CHECK_FUNCS([dup2 gethostname gettimeofday strerror])
8484
AC_CHECK_FUNCS([socket])
8585
AC_CHECK_FUNCS([memchr memmove memset])
8686
AC_CHECK_FUNCS([strchr strndup strtoul])
87+
AC_CHECK_FUNCS([strdup])
8788

8889
AC_CACHE_CHECK([if epoll works], [ac_cv_epoll_works],
8990
AC_TRY_RUN([

src/hashkit/nc_crc32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ hash_crc32(const char *key, size_t key_length)
111111
uint32_t
112112
hash_crc32a(const char *key, size_t key_length)
113113
{
114-
const uint8_t *p = key;
114+
const uint8_t *p = (const uint8_t *)key;
115115
uint32_t crc;
116116

117117
crc = ~0U;

src/test_all.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,19 @@ static void test_hash_algorithms(void) {
4242
/* refer to libmemcached tests/hash_results.h */
4343
expect_same_uint32_t(2297466611U, hash_one_at_a_time("apple", 5), "should have expected one_at_a_time hash for key \"apple\"");
4444
expect_same_uint32_t(3195025439U, hash_md5("apple", 5), "should have expected md5 hash for key \"apple\"");
45+
46+
expect_same_uint32_t(3662830516U, hash_crc16("apple", 5), "should have expected crc16 hash for key \"apple\"");
47+
expect_same_uint32_t(10542U, hash_crc32("apple", 5), "should have expected crc32 hash for key \"apple\"");
48+
expect_same_uint32_t(2838417488U, hash_crc32a("apple", 5), "should have expected crc32a hash for key \"apple\"");
49+
expect_same_uint32_t(67176023U, hash_fnv1_32("apple", 5), "should have expected fnv1_32 hash for key \"apple\"");
50+
expect_same_uint32_t(280767167U, hash_fnv1a_32("apple", 5), "should have expected fnv1a_32 hash for key \"apple\"");
51+
expect_same_uint32_t(473199127U, hash_fnv1_64("apple", 5), "should have expected fnv1_64 hash for key \"apple\"");
52+
expect_same_uint32_t(1488911807U, hash_fnv1a_64("apple", 5), "should have expected fnv1a_64 hash for key \"apple\"");
53+
expect_same_uint32_t(3738850110U, hash_hsieh("apple", 5), "should have expected hsieh hash for key \"apple\"");
54+
expect_same_uint32_t(1442444624U, hash_jenkins("apple", 5), "should have expected jenkins hash for key \"apple\"");
55+
expect_same_uint32_t(4142305122U, hash_murmur("apple", 5), "should have expected murmur hash for key \"apple\"");
56+
/* The above have exactly the same result as libmemcached/tests/hash_results.h */
57+
4558
expect_same_uint32_t(3853726576U, ketama_hash("server1-8", strlen("server1-8"), 0), "should have expected ketama_hash for server1-8 index 0");
4659
expect_same_uint32_t(2667054752U, ketama_hash("server1-8", strlen("server1-8"), 3), "should have expected ketama_hash for server1-8 index 3");
4760
}

0 commit comments

Comments
 (0)