]>
git.saurik.com Git - apple/libc.git/blob - tests/os_simple_hash.c
1 #include <darwintest.h>
5 T_DECL(os_simple_hash
, "sanity check of os_simple_hash",
6 T_META_ALL_VALID_ARCHS(true))
9 "We made the buttons on the screen look so good you'll want to lick them.";
10 uint64_t hashval
= os_simple_hash_string(string
);
11 T_EXPECT_NE(hashval
, 0ULL, "usually should get a non-0 hash value");
14 arc4random_buf(buf
, sizeof(buf
));
15 hashval
= os_simple_hash(buf
, sizeof(buf
));
16 T_EXPECT_NE(hashval
, 0ULL, "usually should get a non-0 hash value");
19 T_DECL(os_simple_hash_seeds
, "os_simple_hash different seeds give different hashes",
20 T_META_ALL_VALID_ARCHS(true))
23 "We made the buttons on the screen look so good you'll want to lick them.";
25 uint64_t hashval0
= os_simple_hash_string_with_seed(string
, 0x0);
26 T_EXPECT_NE(hashval0
, 0ULL, "usually should get a non-0 hash value");
27 uint64_t hashval1
= os_simple_hash_string_with_seed(string
, 0x1);
28 T_EXPECT_NE(hashval1
, 0ULL, "usually should get a non-0 hash value");
29 uint64_t hashvalF
= os_simple_hash_string_with_seed(string
, 0xF);
30 T_EXPECT_NE(hashvalF
, 0ULL, "usually should get a non-0 hash value");
31 uint64_t hashvalFoo
= os_simple_hash_string_with_seed(string
, 0xF0000000);
32 T_EXPECT_NE(hashvalFoo
, 0ULL, "usually should get a non-0 hash value");
34 T_EXPECT_NE(hashval0
, hashval1
, NULL
);
35 T_EXPECT_NE(hashval0
, hashvalF
, NULL
);
36 T_EXPECT_NE(hashval0
, hashvalFoo
, NULL
);
37 T_EXPECT_NE(hashval1
, hashvalF
, NULL
);
38 T_EXPECT_NE(hashval1
, hashvalFoo
, NULL
);
39 T_EXPECT_NE(hashvalF
, hashvalFoo
, NULL
);