@@ -89,6 +89,16 @@ namespace sparrow_ipc
8989 }
9090 }
9191
92+ template <typename T>
93+ void compare_values (sparrow::primitive_array<T>& pa1, sparrow::primitive_array<T>& pa2)
94+ {
95+ CHECK_EQ (pa1.size (), pa1.size ());
96+ for (size_t i = 0 ; i < pa1.size (); ++i)
97+ {
98+ CHECK_EQ (pa1[i], pa2[i]);
99+ }
100+ }
101+
92102 template <typename T>
93103 void compare_bitmap (sparrow::primitive_array<T>& pa1, sparrow::primitive_array<T>& pa2)
94104 {
@@ -131,6 +141,27 @@ namespace sparrow_ipc
131141 }
132142 }
133143
144+ template <typename T>
145+ void compare_primitive_arrays (sparrow::primitive_array<T>& ar, sparrow::primitive_array<T>& deserialized_ar)
146+ {
147+ auto [arrow_array_ar, arrow_schema_ar] = sp::get_arrow_structures (ar);
148+ auto [arrow_array_deserialized_ar, arrow_schema_deserialized_ar] = sp::get_arrow_structures (deserialized_ar);
149+
150+ // Check ArrowSchema equality
151+ REQUIRE_NE (arrow_schema_ar, nullptr );
152+ REQUIRE_NE (arrow_schema_deserialized_ar, nullptr );
153+ compare_arrow_schemas (*arrow_schema_ar, *arrow_schema_deserialized_ar);
154+
155+ // Check ArrowArray equality
156+ REQUIRE_NE (arrow_array_ar, nullptr );
157+ REQUIRE_NE (arrow_array_deserialized_ar, nullptr );
158+ compare_arrow_arrays (*arrow_array_ar, *arrow_array_deserialized_ar);
159+
160+ compare_values<T>(ar, deserialized_ar);
161+ compare_bitmap<T>(ar, deserialized_ar);
162+ compare_metadata<T>(ar, deserialized_ar);
163+ }
164+
134165 TEST_CASE_TEMPLATE_DEFINE (" Serialize and Deserialize primitive_array" , T, primitive_array_types)
135166 {
136167 auto create_primitive_array = []() -> sp::primitive_array<T> {
@@ -160,21 +191,7 @@ namespace sparrow_ipc
160191
161192 sp::primitive_array<T> deserialized_ar = deserialize_primitive_array<T>(serialized_data);
162193
163- auto [arrow_array_ar, arrow_schema_ar] = sp::get_arrow_structures (ar);
164- auto [arrow_array_deserialized_ar, arrow_schema_deserialized_ar] = sp::get_arrow_structures (deserialized_ar);
165-
166- // Check ArrowSchema equality
167- REQUIRE_NE (arrow_schema_ar, nullptr );
168- REQUIRE_NE (arrow_schema_deserialized_ar, nullptr );
169- compare_arrow_schemas (*arrow_schema_ar, *arrow_schema_deserialized_ar);
170-
171- // Check ArrowArray equality
172- REQUIRE_NE (arrow_array_ar, nullptr );
173- REQUIRE_NE (arrow_array_deserialized_ar, nullptr );
174- compare_arrow_arrays (*arrow_array_ar, *arrow_array_deserialized_ar);
175-
176- compare_bitmap<T>(ar, deserialized_ar);
177- compare_metadata<T>(ar, deserialized_ar);
194+ compare_primitive_arrays<T>(ar, deserialized_ar);
178195 }
179196
180197 TEST_CASE_TEMPLATE_APPLY (primitive_array_types, testing_types);
0 commit comments