@@ -249,26 +249,26 @@ BOOST_AUTO_TEST_CASE(streams_serializedata_xor)
249249BOOST_AUTO_TEST_CASE (streams_buffered_file)
250250{
251251 fs::path streams_test_filename = m_args.GetDataDirBase () / " streams_test_tmp" ;
252- FILE* file = fsbridge::fopen (streams_test_filename, " w+b" );
252+ CAutoFile file{ fsbridge::fopen (streams_test_filename, " w+b" ), 333 } ;
253253
254254 // The value at each offset is the offset.
255255 for (uint8_t j = 0 ; j < 40 ; ++j) {
256- fwrite (&j, 1 , 1 , file) ;
256+ file << j ;
257257 }
258- rewind (file);
258+ std:: rewind (file. Get () );
259259
260260 // The buffer size (second arg) must be greater than the rewind
261261 // amount (third arg).
262262 try {
263- BufferedFile bfbad{file, 25 , 25 , 333 };
263+ BufferedFile bfbad{file. Get () , 25 , 25 , 333 };
264264 BOOST_CHECK (false );
265265 } catch (const std::exception& e) {
266266 BOOST_CHECK (strstr (e.what (),
267267 " Rewind limit must be less than buffer size" ) != nullptr );
268268 }
269269
270270 // The buffer is 25 bytes, allow rewinding 10 bytes.
271- BufferedFile bf{file, 25 , 10 , 333 };
271+ BufferedFile bf{file. Get () , 25 , 10 , 333 };
272272 BOOST_CHECK (!bf.eof ());
273273
274274 // This member has no functional effect.
@@ -375,23 +375,23 @@ BOOST_AUTO_TEST_CASE(streams_buffered_file)
375375 BOOST_CHECK (bf.GetPos () <= 30U );
376376
377377 // We can explicitly close the file, or the destructor will do it.
378- bf .fclose ();
378+ file .fclose ();
379379
380380 fs::remove (streams_test_filename);
381381}
382382
383383BOOST_AUTO_TEST_CASE (streams_buffered_file_skip)
384384{
385385 fs::path streams_test_filename = m_args.GetDataDirBase () / " streams_test_tmp" ;
386- FILE* file = fsbridge::fopen (streams_test_filename, " w+b" );
386+ CAutoFile file{ fsbridge::fopen (streams_test_filename, " w+b" ), 333 } ;
387387 // The value at each offset is the byte offset (e.g. byte 1 in the file has the value 0x01).
388388 for (uint8_t j = 0 ; j < 40 ; ++j) {
389- fwrite (&j, 1 , 1 , file) ;
389+ file << j ;
390390 }
391- rewind (file);
391+ std:: rewind (file. Get () );
392392
393393 // The buffer is 25 bytes, allow rewinding 10 bytes.
394- BufferedFile bf{file, 25 , 10 , 333 };
394+ BufferedFile bf{file. Get () , 25 , 10 , 333 };
395395
396396 uint8_t i;
397397 // This is like bf >> (7-byte-variable), in that it will cause data
@@ -425,7 +425,7 @@ BOOST_AUTO_TEST_CASE(streams_buffered_file_skip)
425425 bf.SkipTo (13 );
426426 BOOST_CHECK_EQUAL (bf.GetPos (), 13U );
427427
428- bf .fclose ();
428+ file .fclose ();
429429 fs::remove (streams_test_filename);
430430}
431431
@@ -436,16 +436,16 @@ BOOST_AUTO_TEST_CASE(streams_buffered_file_rand)
436436
437437 fs::path streams_test_filename = m_args.GetDataDirBase () / " streams_test_tmp" ;
438438 for (int rep = 0 ; rep < 50 ; ++rep) {
439- FILE* file = fsbridge::fopen (streams_test_filename, " w+b" );
439+ CAutoFile file{ fsbridge::fopen (streams_test_filename, " w+b" ), 333 } ;
440440 size_t fileSize = InsecureRandRange (256 );
441441 for (uint8_t i = 0 ; i < fileSize; ++i) {
442- fwrite (&i, 1 , 1 , file) ;
442+ file << i ;
443443 }
444- rewind (file);
444+ std:: rewind (file. Get () );
445445
446446 size_t bufSize = InsecureRandRange (300 ) + 1 ;
447447 size_t rewindSize = InsecureRandRange (bufSize);
448- BufferedFile bf{file, bufSize, rewindSize, 333 };
448+ BufferedFile bf{file. Get () , bufSize, rewindSize, 333 };
449449 size_t currentPos = 0 ;
450450 size_t maxPos = 0 ;
451451 for (int step = 0 ; step < 100 ; ++step) {
0 commit comments