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

Function TEST

cpp/src/gandiva/hash_utils_test.cc:24–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22#include "gandiva/hash_utils.h"
23
24TEST(TestShaHashUtils, TestSha1Numeric) {
25 gandiva::ExecutionContext ctx;
26
27 auto ctx_ptr = reinterpret_cast<int64_t>(&ctx);
28
29 std::vector<uint64_t> values_to_be_hashed;
30
31 // Generate a list of values to obtains the SHA1 hash
32 values_to_be_hashed.push_back(gandiva::gdv_double_to_long(0.0));
33 values_to_be_hashed.push_back(gandiva::gdv_double_to_long(0.1));
34 values_to_be_hashed.push_back(gandiva::gdv_double_to_long(0.2));
35 values_to_be_hashed.push_back(gandiva::gdv_double_to_long(-0.10000001));
36 values_to_be_hashed.push_back(gandiva::gdv_double_to_long(-0.0000001));
37 values_to_be_hashed.push_back(gandiva::gdv_double_to_long(1.000000));
38 values_to_be_hashed.push_back(gandiva::gdv_double_to_long(-0.0000002));
39 values_to_be_hashed.push_back(gandiva::gdv_double_to_long(0.999999));
40
41 // Checks if the hash value is different for each one of the values
42 std::unordered_set<std::string> sha_values;
43
44 int sha1_size = 40;
45
46 for (auto value : values_to_be_hashed) {
47 int out_length;
48 const char* sha_1 =
49 gandiva::gdv_sha1_hash(ctx_ptr, &value, sizeof(value), &out_length);
50 std::string sha1_as_str(sha_1, out_length);
51 EXPECT_EQ(sha1_as_str.size(), sha1_size);
52
53 // The value cannot exists inside the set with the hash results
54 EXPECT_EQ(sha_values.find(sha1_as_str), sha_values.end());
55 sha_values.insert(sha1_as_str);
56 }
57}
58
59TEST(TestShaHashUtils, TestSha512Numeric) {
60 gandiva::ExecutionContext ctx;

Callers

nothing calls this directly

Calls 10

gdv_double_to_longFunction · 0.85
gdv_sha1_hashFunction · 0.85
gdv_sha512_hashFunction · 0.85
gdv_sha256_hashFunction · 0.85
gdv_md5_hashFunction · 0.85
push_backMethod · 0.80
sizeMethod · 0.45
findMethod · 0.45
endMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected