MCPcopy Create free account
hub / github.com/apache/arrow / TEST

Function TEST

cpp/src/gandiva/precompiled/hash_test.cc:25–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23namespace gandiva {
24
25TEST(TestHash, TestHash32) {
26 gdv_int8 s8 = 0;
27 gdv_uint8 u8 = 0;
28 gdv_int16 s16 = 0;
29 gdv_uint16 u16 = 0;
30 gdv_int32 s32 = 0;
31 gdv_uint32 u32 = 0;
32 gdv_int64 s64 = 0;
33 gdv_uint64 u64 = 0;
34 gdv_float32 f32 = 0;
35 gdv_float64 f64 = 0;
36
37 // hash of 0 should be non-zero (zero is the hash value for nulls).
38 gdv_int32 zero_hash = hash32(s8, 0);
39 EXPECT_NE(zero_hash, 0);
40
41 // for a given value, all numeric types must have the same hash.
42 EXPECT_EQ(hash32(u8, 0), zero_hash);
43 EXPECT_EQ(hash32(s16, 0), zero_hash);
44 EXPECT_EQ(hash32(u16, 0), zero_hash);
45 EXPECT_EQ(hash32(s32, 0), zero_hash);
46 EXPECT_EQ(hash32(u32, 0), zero_hash);
47 EXPECT_EQ(hash32(static_cast<double>(s64), 0), zero_hash);
48 EXPECT_EQ(hash32(static_cast<double>(u64), 0), zero_hash);
49 EXPECT_EQ(hash32(f32, 0), zero_hash);
50 EXPECT_EQ(hash32(f64, 0), zero_hash);
51
52 // hash must change with a change in seed.
53 EXPECT_NE(hash32(s8, 1), zero_hash);
54
55 // for a given value and seed, all numeric types must have the same hash.
56 EXPECT_EQ(hash32(s8, 1), hash32(s16, 1));
57 EXPECT_EQ(hash32(s8, 1), hash32(u32, 1));
58 EXPECT_EQ(hash32(s8, 1), hash32(f32, 1));
59 EXPECT_EQ(hash32(s8, 1), hash32(f64, 1));
60}
61
62TEST(TestHash, TestHash64) {
63 gdv_int8 s8 = 0;

Callers

nothing calls this directly

Calls 4

hash32Function · 0.85
hash64Function · 0.85
hash32_bufFunction · 0.85
hash64_bufFunction · 0.85

Tested by

no test coverage detected