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

Method TestString

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

Source from the content-addressed store, hash-verified

188}
189
190void IcebergTruncatePartitionTransformTests::TestString() {
191 MemTracker m;
192 MemPool pool(&m);
193 StringVal input("Some test input");
194 FunctionContext* ctx = CreateFunctionContext(&pool);
195
196 int width = 10;
197 StringVal ret_val = IcebergFunctions::TruncatePartitionTransform<false>(
198 ctx, input, IntVal(width));
199 EXPECT_EQ(ret_val.len, width);
200 EXPECT_EQ(strncmp((char*)input.ptr, (char*)ret_val.ptr, width), 0);
201
202 // Truncate width is longer than the input string.
203 ret_val = IcebergFunctions::TruncatePartitionTransform<false>(ctx, input, 100);
204 EXPECT_EQ(ret_val.len, input.len);
205 EXPECT_EQ(strncmp((char*)input.ptr, (char*)ret_val.ptr, input.len), 0);
206
207 // Truncate width is the same as the the input string length.
208 ret_val = IcebergFunctions::TruncatePartitionTransform<false>(ctx, input, input.len);
209 EXPECT_EQ(ret_val.len, input.len);
210 EXPECT_EQ(strncmp((char*)input.ptr, (char*)ret_val.ptr, input.len), 0);
211
212 // Test NULL input.
213 ret_val = IcebergFunctions::TruncatePartitionTransform<false>(
214 nullptr, StringVal::null(), IntVal(10));
215 EXPECT_TRUE(ret_val.is_null);
216
217 // Test empty string input.
218 ctx = CreateFunctionContext(&pool);
219 ret_val = IcebergFunctions::TruncatePartitionTransform<false>(ctx, "", 10);
220 EXPECT_EQ(ret_val.len, 0);
221
222 TestIncorrectWidthParameter<StringVal, IntVal>(StringVal("input"));
223
224 pool.FreeAll();
225}
226
227void IcebergTruncatePartitionTransformTests::TestBinary() {
228 MemTracker m;

Callers

nothing calls this directly

Calls 4

CreateFunctionContextFunction · 0.85
IntValClass · 0.85
StringValClass · 0.85
FreeAllMethod · 0.45

Tested by

no test coverage detected