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

Method TestIntegerNumbersHelper

be/src/exprs/iceberg-functions-test.cc:122–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120
121template<typename T>
122void IcebergTruncatePartitionTransformTests::TestIntegerNumbersHelper() {
123 // Test positive inputs.
124 T ret_val = IcebergFunctions::TruncatePartitionTransform(
125 nullptr, T(15), T(10));
126 EXPECT_EQ(10, ret_val.val);
127
128 ret_val = IcebergFunctions::TruncatePartitionTransform(
129 nullptr, T(15), T(4));
130 EXPECT_EQ(12, ret_val.val);
131
132 // Test negative inputs.
133 ret_val = IcebergFunctions::TruncatePartitionTransform(
134 nullptr, T(-1), T(10));
135 EXPECT_EQ(-10, ret_val.val);
136
137 ret_val = IcebergFunctions::TruncatePartitionTransform(
138 nullptr, T(-15), T(4));
139 EXPECT_EQ(-16, ret_val.val);
140
141 ret_val = IcebergFunctions::TruncatePartitionTransform(
142 nullptr, T(-15), T(1));
143 EXPECT_EQ(-15, ret_val.val);
144
145 // Test NULL input.
146 ret_val = IcebergFunctions::TruncatePartitionTransform(
147 nullptr, T::null(), T(10));
148 EXPECT_TRUE(ret_val.is_null);
149
150 // Check for overflow when truncating from min value
151 FunctionContext* ctx = CreateFunctionContext();
152 typename T::underlying_type_t num_min =
153 std::numeric_limits<typename T::underlying_type_t>::min();
154 ret_val = IcebergFunctions::TruncatePartitionTransform(ctx, T(num_min), T(10000));
155 EXPECT_TRUE(ret_val.is_null);
156 EXPECT_EQ(strcmp("Truncate operation overflows for the given input.",
157 ctx->error_msg()), 0);
158 ctx->impl()->Close();
159
160 TestIncorrectWidthParameter<T, T>(T(0));
161}
162
163template<>
164void IcebergTruncatePartitionTransformTests::TestIncorrectWidthParameter

Callers

nothing calls this directly

Calls 6

CreateFunctionContextFunction · 0.85
minFunction · 0.85
error_msgMethod · 0.80
implMethod · 0.80
TFunction · 0.50
CloseMethod · 0.45

Tested by

no test coverage detected