forked from OSchip/llvm-project
Provide the 32-bit variant of the golden tests. Not sure how I forgot to
do this initially, sorry. llvm-svn: 151857
This commit is contained in:
parent
57207d6074
commit
3da579832f
|
@ -161,6 +161,7 @@ TEST(HashingTest, HashCombineRangeLengthDiff) {
|
||||||
|
|
||||||
TEST(HashingTest, HashCombineRangeGoldenTest) {
|
TEST(HashingTest, HashCombineRangeGoldenTest) {
|
||||||
struct { const char *s; uint64_t hash; } golden_data[] = {
|
struct { const char *s; uint64_t hash; } golden_data[] = {
|
||||||
|
#if SIZE_MAX == UINT64_MAX
|
||||||
{ "a", 0xaeb6f9d5517c61f8ULL },
|
{ "a", 0xaeb6f9d5517c61f8ULL },
|
||||||
{ "ab", 0x7ab1edb96be496b4ULL },
|
{ "ab", 0x7ab1edb96be496b4ULL },
|
||||||
{ "abc", 0xe38e60bf19c71a3fULL },
|
{ "abc", 0xe38e60bf19c71a3fULL },
|
||||||
|
@ -212,14 +213,70 @@ TEST(HashingTest, HashCombineRangeGoldenTest) {
|
||||||
"abababababababababababababababab"
|
"abababababababababababababababab"
|
||||||
"abababababababababababababababab"
|
"abababababababababababababababab"
|
||||||
"abababababababababababababababab", 0x840192d129f7a22bULL }
|
"abababababababababababababababab", 0x840192d129f7a22bULL }
|
||||||
|
#elif SIZE_MAX == UINT32_MAX
|
||||||
|
{ "a", 0x000000004605f745ULL },
|
||||||
|
{ "ab", 0x00000000d5f06301ULL },
|
||||||
|
{ "abc", 0x00000000559fe1eeULL },
|
||||||
|
{ "abcde", 0x00000000424028d7ULL },
|
||||||
|
{ "abcdefgh", 0x000000007bb119f8ULL },
|
||||||
|
{ "abcdefghijklm", 0x00000000edbca513ULL },
|
||||||
|
{ "abcdefghijklmnopqrstu", 0x000000007c15712eULL },
|
||||||
|
{ "abcdefghijklmnopqrstuvwxyzabcdef", 0x000000000b3aad66ULL },
|
||||||
|
{ "abcdefghijklmnopqrstuvwxyzabcdef"
|
||||||
|
"abcdefghijklmnopqrstuvwxyzghijkl"
|
||||||
|
"abcdefghijklmnopqrstuvwxyzmnopqr"
|
||||||
|
"abcdefghijklmnopqrstuvwxyzstuvwx"
|
||||||
|
"abcdefghijklmnopqrstuvwxyzyzabcd", 0x000000008c758c8bULL },
|
||||||
|
{ "a", 0x000000004605f745ULL },
|
||||||
|
{ "aa", 0x00000000dc0a52daULL },
|
||||||
|
{ "aaa", 0x00000000b309274fULL },
|
||||||
|
{ "aaaaa", 0x00000000203b5ef6ULL },
|
||||||
|
{ "aaaaaaaa", 0x00000000a429e18fULL },
|
||||||
|
{ "aaaaaaaaaaaaa", 0x000000008662070bULL },
|
||||||
|
{ "aaaaaaaaaaaaaaaaaaaaa", 0x000000003f11151cULL },
|
||||||
|
{ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 0x000000008600fe20ULL },
|
||||||
|
{ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||||
|
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||||
|
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||||
|
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||||
|
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 0x000000004e0e0804ULL },
|
||||||
|
{ "z", 0x00000000c5e405e9ULL },
|
||||||
|
{ "zz", 0x00000000a8d8a2c6ULL },
|
||||||
|
{ "zzz", 0x00000000fc2af672ULL },
|
||||||
|
{ "zzzzz", 0x0000000047d9efe6ULL },
|
||||||
|
{ "zzzzzzzz", 0x0000000080d77794ULL },
|
||||||
|
{ "zzzzzzzzzzzzz", 0x00000000405f93adULL },
|
||||||
|
{ "zzzzzzzzzzzzzzzzzzzzz", 0x00000000fc72838dULL },
|
||||||
|
{ "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", 0x000000007ce160f1ULL },
|
||||||
|
{ "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
|
||||||
|
"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
|
||||||
|
"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
|
||||||
|
"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
|
||||||
|
"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", 0x00000000aed9ed1bULL },
|
||||||
|
{ "a", 0x000000004605f745ULL },
|
||||||
|
{ "ab", 0x00000000d5f06301ULL },
|
||||||
|
{ "aba", 0x00000000a85cd91bULL },
|
||||||
|
{ "ababa", 0x000000009e3bb52eULL },
|
||||||
|
{ "abababab", 0x000000002709b3b9ULL },
|
||||||
|
{ "ababababababa", 0x000000003a234174ULL },
|
||||||
|
{ "ababababababababababa", 0x000000005c63e5ceULL },
|
||||||
|
{ "abababababababababababababababab", 0x0000000013f74334ULL },
|
||||||
|
{ "abababababababababababababababab"
|
||||||
|
"abababababababababababababababab"
|
||||||
|
"abababababababababababababababab"
|
||||||
|
"abababababababababababababababab"
|
||||||
|
"abababababababababababababababab", 0x00000000c1a6f135ULL },
|
||||||
|
#else
|
||||||
|
#error This test only supports 64-bit and 32-bit systems.
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
for (unsigned i = 0; i < sizeof(golden_data)/sizeof(*golden_data); ++i) {
|
for (unsigned i = 0; i < sizeof(golden_data)/sizeof(*golden_data); ++i) {
|
||||||
StringRef str = golden_data[i].s;
|
StringRef str = golden_data[i].s;
|
||||||
hash_code hash = hash_combine_range(str.begin(), str.end());
|
hash_code hash = hash_combine_range(str.begin(), str.end());
|
||||||
#if 0 // Enable this to generate paste-able text for the above structure.
|
#if 1 // Enable this to generate paste-able text for the above structure.
|
||||||
std::string member_str = "\"" + str.str() + "\",";
|
std::string member_str = "\"" + str.str() + "\",";
|
||||||
fprintf(stderr, " { %-35s 0x%016lxULL },\n",
|
fprintf(stderr, " { %-35s 0x%016llxULL },\n",
|
||||||
member_str.c_str(), (size_t)hash);
|
member_str.c_str(), static_cast<uint64_t>(hash));
|
||||||
#endif
|
#endif
|
||||||
EXPECT_EQ(static_cast<size_t>(golden_data[i].hash),
|
EXPECT_EQ(static_cast<size_t>(golden_data[i].hash),
|
||||||
static_cast<size_t>(hash));
|
static_cast<size_t>(hash));
|
||||||
|
|
Loading…
Reference in New Issue