MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / TEST_F

Function TEST_F

test/api/arrow_table_function_test.cpp:17–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15};
16
17TEST_F(ArrowTableFunctionTest, CreateArrowTable) {
18 // Create simple test data
19 std::vector<int32_t> intData = {1, 2, 3};
20
21 // Create Arrow schema
22 ArrowSchemaWrapper schema;
23 createStructSchema(&schema, 1);
24 createSchema<int32_t>(schema.children[0], "id");
25
26 // Create Arrow array
27 ArrowArray array;
28 array.length = intData.size();
29 array.null_count = 0;
30 array.offset = 0;
31 array.n_buffers = 1;
32 array.n_children = 1;
33 array.buffers = static_cast<const void**>(malloc(sizeof(void*)));
34 array.buffers[0] = nullptr;
35 array.children = static_cast<ArrowArray**>(malloc(sizeof(ArrowArray*)));
36 array.children[0] = static_cast<ArrowArray*>(malloc(sizeof(ArrowArray)));
37 createInt32Array(array.children[0], intData);
38 array.dictionary = nullptr;
39 array.release = [](ArrowArray* arr) {
40 if (arr->children) {
41 for (int64_t i = 0; i < arr->n_children; i++) {
42 if (arr->children[i]->release) {
43 arr->children[i]->release(arr->children[i]);
44 }
45 free(arr->children[i]);
46 }
47 free(arr->children);
48 }
49 if (arr->buffers) {
50 free(const_cast<void**>(arr->buffers));
51 }
52 arr->release = nullptr;
53 };
54 array.private_data = nullptr;
55
56 // Test that we can create arrays with Arrow C Data Interface
57 EXPECT_EQ(array.length, 3);
58 EXPECT_EQ(array.n_children, 1);
59 EXPECT_STREQ(schema.children[0]->name, "id");
60
61 // Cleanup
62 if (schema.release)
63 schema.release(&schema);
64 if (array.release)
65 array.release(&array);
66}
67
68TEST_F(ArrowTableFunctionTest, CreateArrowTableMultipleColumns) {
69 // Create test data with multiple columns

Callers

nothing calls this directly

Calls 10

createStructSchemaFunction · 0.85
createInt32ArrayFunction · 0.85
createStringArrayFunction · 0.85
createDoubleArrayFunction · 0.85
releaseMethod · 0.80
sizeMethod · 0.45
push_backMethod · 0.45
isSuccessMethod · 0.45
getErrorMessageMethod · 0.45
queryMethod · 0.45

Tested by

no test coverage detected