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

Function TEST

be/src/runtime/multi-precision-test.cc:33–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31namespace impala {
32
33TEST(MultiPrecisionIntTest, Conversion) {
34 int128_t x = 0;
35 int256_t y = 0;
36 EXPECT_TRUE(ConvertToInt256(x) == 0);
37
38 x = -1;
39 EXPECT_TRUE(ConvertToInt256(x) == -1);
40
41 x = 1;
42 EXPECT_TRUE(ConvertToInt256(x) == 1);
43
44 x = numeric_limits<int32_t>::max();
45 EXPECT_TRUE(ConvertToInt256(x) == numeric_limits<int32_t>::max());
46
47 x = numeric_limits<int32_t>::min();
48 EXPECT_TRUE(ConvertToInt256(x) == numeric_limits<int32_t>::min());
49
50 x = numeric_limits<int64_t>::max();
51 EXPECT_TRUE(ConvertToInt256(x) == numeric_limits<int64_t>::max());
52
53 x = numeric_limits<int64_t>::min();
54 EXPECT_TRUE(ConvertToInt256(x) == numeric_limits<int64_t>::min());
55
56 x = numeric_limits<int64_t>::max();
57 x *= 1000;
58 y = numeric_limits<int64_t>::max();
59 y *= 1000;
60 EXPECT_TRUE(ConvertToInt256(x) == y);
61
62 x = -numeric_limits<int64_t>::max();
63 x *= 1000;
64 y = -numeric_limits<int64_t>::max();
65 y *= 1000;
66 EXPECT_TRUE(ConvertToInt256(x) == y);
67
68 // Note: numer_limits<> doesn't work for int128_t.
69 static int128_t MAX_VALUE;
70 memset(&MAX_VALUE, 255, sizeof(MAX_VALUE));
71 uint8_t* buf = reinterpret_cast<uint8_t*>(&MAX_VALUE);
72 buf[15] = 127;
73
74 bool overflow = false;
75 EXPECT_TRUE(ConvertToInt128(ConvertToInt256(x), MAX_VALUE, &overflow) == x);
76 EXPECT_FALSE(overflow);
77}
78
79TEST(MultiPrecisionIntTest, HighLowBits) {
80 // x = 0x0f0e0d0c0b0a09080706050403020100

Callers

nothing calls this directly

Calls 8

ConvertToInt256Function · 0.85
maxFunction · 0.85
minFunction · 0.85
ConvertToInt128Function · 0.85
LowBitsFunction · 0.85
HighBitsFunction · 0.85
area_of_a_circleFunction · 0.85
strMethod · 0.45

Tested by

no test coverage detected