diff options
author | Simo Sorce <simo@redhat.com> | 2011-12-27 19:56:43 -0500 |
---|---|---|
committer | Simo Sorce <simo@redhat.com> | 2012-01-09 15:00:32 -0500 |
commit | 5a70b84cb66fb8c7a3fce0e3f2e4b61e0b2ea9d4 (patch) | |
tree | d60aab13a1253480b797c0615c25487759ff0490 /src/tests | |
parent | a096f75242bb612b7a1ae126c8e960934dc85fd4 (diff) | |
download | sssd-5a70b84cb66fb8c7a3fce0e3f2e4b61e0b2ea9d4.tar.gz sssd-5a70b84cb66fb8c7a3fce0e3f2e4b61e0b2ea9d4.tar.bz2 sssd-5a70b84cb66fb8c7a3fce0e3f2e4b61e0b2ea9d4.zip |
util: add murmurhash3 hash function
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/util-tests.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/tests/util-tests.c b/src/tests/util-tests.c index c6973d33..557be10e 100644 --- a/src/tests/util-tests.c +++ b/src/tests/util-tests.c @@ -27,6 +27,7 @@ #include <check.h> #include "util/util.h" #include "util/sss_utf8.h" +#include "util/murmurhash3.h" #include "tests/common.h" START_TEST(test_parse_args) @@ -398,6 +399,24 @@ START_TEST(test_utf8_check) } END_TEST +START_TEST(test_murmurhash3_check) +{ + const char *tests[6] = { "1052800007", "1052800008", "1052800000", + "abcdefghijk", "abcdefghili", "abcdefgh000" }; + uint32_t results[6]; + int i, j; + + for (i = 0; i< 6; i++) { + results[i] = murmurhash3(tests[i], + strlen(tests[i]), + 0xdeadbeef); + for (j = 0; j < i; j++) { + fail_if(results[i] == results[j]); + } + } +} +END_TEST + Suite *util_suite(void) { Suite *s = suite_create("util"); @@ -419,8 +438,13 @@ Suite *util_suite(void) tcase_set_timeout(tc_utf8, 60); + TCase *tc_mh3 = tcase_create("murmurhash3"); + tcase_add_test (tc_mh3, test_murmurhash3_check); + tcase_set_timeout(tc_mh3, 60); + suite_add_tcase (s, tc_util); suite_add_tcase (s, tc_utf8); + suite_add_tcase (s, tc_mh3); return s; } |