@@ -113,12 +113,12 @@ TEST(TestHTTPFile, TestWriteSmallFile) {
113113 std::unique_ptr<XrdOssDF> fh (fs.newFile ());
114114 auto rc =
115115 fh->Open (" /test_write.txt" , O_WRONLY | O_CREAT | O_TRUNC, 0644 , env);
116- auto rc = fh->Open (" /test_write.txt" , O_WRONLY | O_CREAT | O_TRUNC, 0644 , env);
116+ auto rc =
117+ fh->Open (" /test_write.txt" , O_WRONLY | O_CREAT | O_TRUNC, 0644 , env);
117118 ASSERT_EQ (rc, 0 );
118119
119120 // Write some test data
120121 const char test_data[] = " This is a test file for writing operations." ;
121-
122122 auto write_res = fh->Write (test_data, 0 , data_size);
123123 ASSERT_EQ (write_res, static_cast <ssize_t >(data_size));
124124
@@ -148,32 +148,26 @@ TEST(TestHTTPFile, TestWriteLargeFile) {
148148 HTTPFileSystem fs (&log, g_config_file.c_str (), nullptr );
149149
150150 XrdOucEnv env;
151- std::unique_ptr<XrdOssDF> fh (fs. newFile ());
152-
153- // Create a large file (2 MB)
154- auto rc = fh-> Open ( " /test_large_file.txt " , O_WRONLY | O_CREAT | O_TRUNC, 0644 , env);
151+ auto rc = fh-> Open ( " /test_large_file.txt " , O_WRONLY | O_CREAT | O_TRUNC,
152+ 0644 , env);
153+ auto rc = fh-> Open ( " /test_large_file.txt " , O_WRONLY | O_CREAT | O_TRUNC,
154+ 0644 , env);
155155 ASSERT_EQ (rc, 0 );
156156
157157 // Generate 2 MB of test data
158158 const size_t file_size = 2 * 1024 * 1024 ; // 2 MB
159- std::vector<char > test_data (file_size);
160-
161159 // Fill with a repeating pattern for easy verification
162160 for (size_t i = 0 ; i < file_size; i++) {
163161 test_data[i] = static_cast <char >(i % 256 );
164- }
165-
166162 // Write the data in chunks to test streaming upload
167163 const size_t chunk_size = 64 * 1024 ; // 64 KB chunks
168- size_t total_written = 0 ;
169-
170164 for (size_t offset = 0 ; offset < file_size; offset += chunk_size) {
171- size_t current_chunk_size = std::min (chunk_size, file_size - offset);
172- auto write_res = fh->Write (&test_data[offset], offset, current_chunk_size);
165+ auto write_res =
166+ fh->Write (&test_data[offset], offset, current_chunk_size);
167+ auto write_res =
168+ fh->Write (&test_data[offset], offset, current_chunk_size);
173169 ASSERT_EQ (write_res, static_cast <ssize_t >(current_chunk_size));
174170 total_written += current_chunk_size;
175- }
176-
177171 ASSERT_EQ (total_written, file_size);
178172 ASSERT_EQ (fh->Close (), 0 );
179173
@@ -190,15 +184,13 @@ TEST(TestHTTPFile, TestWriteLargeFile) {
190184
191185 // Read the data in chunks
192186 std::vector<char > read_buf (file_size);
193- size_t total_read = 0 ;
194-
195187 for (size_t offset = 0 ; offset < file_size; offset += chunk_size) {
196- size_t current_chunk_size = std::min (chunk_size, file_size - offset);
197- auto read_res = read_fh->Read (&read_buf[offset], offset, current_chunk_size);
188+ auto read_res =
189+ read_fh->Read (&read_buf[offset], offset, current_chunk_size);
190+ auto read_res =
191+ read_fh->Read (&read_buf[offset], offset, current_chunk_size);
198192 ASSERT_EQ (read_res, static_cast <ssize_t >(current_chunk_size));
199193 total_read += current_chunk_size;
200- }
201-
202194 ASSERT_EQ (total_read, file_size);
203195 ASSERT_EQ (memcmp (read_buf.data (), test_data.data (), file_size), 0 );
204196
0 commit comments