1111#include " doctest/doctest.h"
1212#include " integration_tools.hpp"
1313#include " sparrow_ipc/deserialize.hpp"
14+ #include " sparrow_ipc/stream_file_serializer.hpp"
1415
1516TEST_SUITE (" Integration Tools Tests" )
1617{
@@ -31,12 +32,12 @@ TEST_SUITE("Integration Tools Tests")
3132 CHECK_THROWS_AS (integration_tools::stream_to_file (std::span<const uint8_t >(empty_data)), std::runtime_error);
3233 }
3334
34- TEST_CASE (" validate_json_against_stream - Non-existent JSON file" )
35+ TEST_CASE (" validate_json_against_arrow_file - Non-existent JSON file" )
3536 {
3637 const std::filesystem::path non_existent = " non_existent_file_12345.json" ;
3738 std::vector<uint8_t > dummy_stream = {1 , 2 , 3 };
3839 CHECK_THROWS_AS (
39- integration_tools::validate_json_against_stream (non_existent, std::span<const uint8_t >(dummy_stream)),
40+ integration_tools::validate_json_against_arrow_file (non_existent, std::span<const uint8_t >(dummy_stream)),
4041 std::runtime_error
4142 );
4243 }
@@ -76,7 +77,7 @@ TEST_SUITE("Integration Tools Tests")
7677 std::ifstream stream_file (input_stream, std::ios::binary);
7778 REQUIRE (stream_file.is_open ());
7879
79- std::vector<uint8_t > input_data (
80+ const std::vector<uint8_t > input_data (
8081 (std::istreambuf_iterator<char >(stream_file)),
8182 std::istreambuf_iterator<char >()
8283 );
@@ -88,7 +89,7 @@ TEST_SUITE("Integration Tools Tests")
8889 CHECK_GT (output_data.size (), 0 );
8990
9091 // Verify the output is valid
91- auto batches = sparrow_ipc::deserialize_stream (std::span<const uint8_t >(output_data));
92+ const auto batches = sparrow_ipc::deserialize_file (std::span<const uint8_t >(output_data));
9293 CHECK_GT (batches.size (), 0 );
9394 }
9495
@@ -103,16 +104,16 @@ TEST_SUITE("Integration Tools Tests")
103104 }
104105
105106 // Step 1: JSON -> stream
106- std::vector<uint8_t > stream_data = integration_tools::json_file_to_stream (json_file);
107+ const std::vector<uint8_t > stream_data = integration_tools::json_file_to_stream (json_file);
107108 REQUIRE_GT (stream_data.size (), 0 );
108109
109110 // Step 2: stream -> file
110- std::vector<uint8_t > file_data = integration_tools::stream_to_file (std::span<const uint8_t >(stream_data));
111+ const std::vector<uint8_t > file_data = integration_tools::stream_to_file (std::span<const uint8_t >(stream_data));
111112 REQUIRE_GT (file_data.size (), 0 );
112113
113114 // Step 3: Compare the results - both should deserialize to same data
114- auto stream_batches = sparrow_ipc::deserialize_stream (std::span<const uint8_t >(stream_data));
115- auto file_batches = sparrow_ipc::deserialize_stream (std::span<const uint8_t >(file_data));
115+ const auto stream_batches = sparrow_ipc::deserialize_stream (std::span<const uint8_t >(stream_data));
116+ const auto file_batches = sparrow_ipc::deserialize_file (std::span<const uint8_t >(file_data));
116117
117118 REQUIRE_EQ (stream_batches.size (), file_batches.size ());
118119 for (size_t i = 0 ; i < stream_batches.size (); ++i)
@@ -121,7 +122,7 @@ TEST_SUITE("Integration Tools Tests")
121122 }
122123 }
123124
124- TEST_CASE (" validate_json_against_stream - Successful validation" )
125+ TEST_CASE (" validate_json_against_arrow_file - Successful validation" )
125126 {
126127 const std::filesystem::path json_file = tests_resources_files_path / " generated_primitive.json" ;
127128
@@ -131,42 +132,41 @@ TEST_SUITE("Integration Tools Tests")
131132 return ;
132133 }
133134
134- // Convert JSON to stream
135- std::vector<uint8_t > stream_data = integration_tools::json_file_to_stream (json_file);
135+ const std::vector<uint8_t > arrow_file_data = integration_tools::json_file_to_arrow_file (json_file);
136136
137137 // Validate
138- bool matches = integration_tools::validate_json_against_stream (
138+ const bool matches = integration_tools::validate_json_against_arrow_file (
139139 json_file,
140- std::span<const uint8_t >(stream_data )
140+ std::span<const uint8_t >(arrow_file_data )
141141 );
142142 CHECK (matches);
143143 }
144144
145- TEST_CASE (" validate_json_against_stream - With reference stream file" )
145+ TEST_CASE (" validate_json_against_arrow_file - With reference stream file" )
146146 {
147147 const std::filesystem::path json_file = tests_resources_files_path / " generated_primitive.json" ;
148- const std::filesystem::path stream_file = tests_resources_files_path / " generated_primitive.stream " ;
148+ const std::filesystem::path arrow_file = tests_resources_files_path / " generated_primitive.arrow_file " ;
149149
150- if (!std::filesystem::exists (json_file) || !std::filesystem::exists (stream_file ))
150+ if (!std::filesystem::exists (json_file) || !std::filesystem::exists (arrow_file ))
151151 {
152152 MESSAGE (" Skipping test: test file(s) not found" );
153153 return ;
154154 }
155155
156156 // Read the stream file
157- std::ifstream stream_input (stream_file , std::ios::binary);
157+ std::ifstream stream_input (arrow_file , std::ios::binary);
158158 REQUIRE (stream_input.is_open ());
159159
160- std::vector<uint8_t > stream_data (
160+ const std::vector<uint8_t > arrow_file_data (
161161 (std::istreambuf_iterator<char >(stream_input)),
162162 std::istreambuf_iterator<char >()
163163 );
164164 stream_input.close ();
165165
166166 // Validate
167- bool matches = integration_tools::validate_json_against_stream (
167+ bool matches = integration_tools::validate_json_against_arrow_file (
168168 json_file,
169- std::span<const uint8_t >(stream_data )
169+ std::span<const uint8_t >(arrow_file_data )
170170 );
171171 CHECK (matches);
172172 }
@@ -182,18 +182,18 @@ TEST_SUITE("Integration Tools Tests")
182182 }
183183
184184 // Convert JSON to stream
185- std::vector<uint8_t > stream_data = integration_tools::json_file_to_stream (json_file);
186- REQUIRE_GT (stream_data .size (), 0 );
185+ const std::vector<uint8_t > arrow_file_data = integration_tools::json_file_to_arrow_file (json_file);
186+ REQUIRE_GT (arrow_file_data .size (), 0 );
187187
188188 // Validate that the stream matches the JSON
189- bool matches = integration_tools::validate_json_against_stream (
189+ const bool matches = integration_tools::validate_json_against_arrow_file (
190190 json_file,
191- std::span<const uint8_t >(stream_data )
191+ std::span<const uint8_t >(arrow_file_data )
192192 );
193193 CHECK (matches);
194194
195195 // Also verify by deserializing
196- auto batches = sparrow_ipc::deserialize_stream (std::span<const uint8_t >(stream_data ));
196+ auto batches = sparrow_ipc::deserialize_file (std::span<const uint8_t >(arrow_file_data ));
197197 CHECK_GT (batches.size (), 0 );
198198 }
199199
@@ -244,18 +244,18 @@ TEST_SUITE("Integration Tools Tests")
244244 SUBCASE (filename.c_str ())
245245 {
246246 // Convert to stream
247- std::vector<uint8_t > stream_data = integration_tools::json_file_to_stream (json_file);
248- REQUIRE_GT (stream_data .size (), 0 );
247+ const std::vector<uint8_t > arrow_file_data = integration_tools::json_file_to_arrow_file (json_file);
248+ REQUIRE_GT (arrow_file_data .size (), 0 );
249249
250250 // Validate
251- bool matches = integration_tools::validate_json_against_stream (
251+ const bool matches = integration_tools::validate_json_against_arrow_file (
252252 json_file,
253- std::span<const uint8_t >(stream_data )
253+ std::span<const uint8_t >(arrow_file_data )
254254 );
255255 CHECK (matches);
256256
257257 // Verify we can deserialize
258- auto batches = sparrow_ipc::deserialize_stream (std::span<const uint8_t >(stream_data ));
258+ const auto batches = sparrow_ipc::deserialize_file (std::span<const uint8_t >(arrow_file_data ));
259259 CHECK_GE (batches.size (), 0 );
260260 }
261261 }
0 commit comments