]> git.saurik.com Git - apple/libc.git/blobdiff - tests/os_simple_hash.c
Libc-1353.11.2.tar.gz
[apple/libc.git] / tests / os_simple_hash.c
index ae1bc4030f2b6adbaa0ddad02339dfdd33d5429a..946ba96ac5ae73109467b4e22c055a3d235980b2 100644 (file)
@@ -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);
+}