X-Git-Url: https://git.saurik.com/apple/libc.git/blobdiff_plain/6dccf0e0b5e80b7b6176e8d332e646175431bb3d..507116e319a1470bb0a5040d4d23e5c76955ef97:/tests/os_simple_hash.c?ds=inline diff --git a/tests/os_simple_hash.c b/tests/os_simple_hash.c index ae1bc40..946ba96 100644 --- a/tests/os_simple_hash.c +++ b/tests/os_simple_hash.c @@ -15,3 +15,26 @@ T_DECL(os_simple_hash, "sanity check of os_simple_hash", hashval = os_simple_hash(buf, sizeof(buf)); T_EXPECT_NE(hashval, 0ULL, "usually should get a non-0 hash value"); } + +T_DECL(os_simple_hash_seeds, "os_simple_hash different seeds give different hashes", + T_META_ALL_VALID_ARCHS(true)) +{ + const char * string = + "We made the buttons on the screen look so good you'll want to lick them."; + + uint64_t hashval0 = os_simple_hash_string_with_seed(string, 0x0); + T_EXPECT_NE(hashval0, 0ULL, "usually should get a non-0 hash value"); + uint64_t hashval1 = os_simple_hash_string_with_seed(string, 0x1); + T_EXPECT_NE(hashval1, 0ULL, "usually should get a non-0 hash value"); + uint64_t hashvalF = os_simple_hash_string_with_seed(string, 0xF); + T_EXPECT_NE(hashvalF, 0ULL, "usually should get a non-0 hash value"); + uint64_t hashvalFoo = os_simple_hash_string_with_seed(string, 0xF0000000); + T_EXPECT_NE(hashvalFoo, 0ULL, "usually should get a non-0 hash value"); + + T_EXPECT_NE(hashval0, hashval1, NULL); + T_EXPECT_NE(hashval0, hashvalF, NULL); + T_EXPECT_NE(hashval0, hashvalFoo, NULL); + T_EXPECT_NE(hashval1, hashvalF, NULL); + T_EXPECT_NE(hashval1, hashvalFoo, NULL); + T_EXPECT_NE(hashvalF, hashvalFoo, NULL); +}