@@ -198,32 +198,28 @@ BOOST_AUTO_TEST_CASE(streams_serializedata_xor)
198198BOOST_AUTO_TEST_CASE (streams_buffered_file)
199199{
200200 fs::path streams_test_filename = m_args.GetDataDirBase () / " streams_test_tmp" ;
201- FILE* file = fsbridge::fopen (streams_test_filename, " w+b" );
201+ AutoFile file{ fsbridge::fopen (streams_test_filename, " w+b" )} ;
202202
203203 // The value at each offset is the offset.
204204 for (uint8_t j = 0 ; j < 40 ; ++j) {
205- fwrite (&j, 1 , 1 , file) ;
205+ file << j ;
206206 }
207- rewind (file );
207+ file. rewind ();
208208
209209 // The buffer size (second arg) must be greater than the rewind
210210 // amount (third arg).
211211 try {
212- CBufferedFile bfbad (file, 25 , 25 , 222 , 333 );
212+ CBufferedFile bfbad (file. Get () , 25 , 25 , 222 , 333 );
213213 BOOST_CHECK (false );
214214 } catch (const std::exception& e) {
215215 BOOST_CHECK (strstr (e.what (),
216216 " Rewind limit must be less than buffer size" ) != nullptr );
217217 }
218218
219219 // The buffer is 25 bytes, allow rewinding 10 bytes.
220- CBufferedFile bf (file, 25 , 10 , 222 , 333 );
220+ CBufferedFile bf (file. Get () , 25 , 10 , 222 , 333 );
221221 BOOST_CHECK (!bf.eof ());
222222
223- // These two members have no functional effect.
224- BOOST_CHECK_EQUAL (bf.GetType (), 222 );
225- BOOST_CHECK_EQUAL (bf.GetVersion (), 333 );
226-
227223 uint8_t i;
228224 bf >> i;
229225 BOOST_CHECK_EQUAL (i, 0 );
@@ -333,15 +329,15 @@ BOOST_AUTO_TEST_CASE(streams_buffered_file)
333329BOOST_AUTO_TEST_CASE (streams_buffered_file_skip)
334330{
335331 fs::path streams_test_filename = m_args.GetDataDirBase () / " streams_test_tmp" ;
336- FILE* file = fsbridge::fopen (streams_test_filename, " w+b" );
332+ AutoFile file{ fsbridge::fopen (streams_test_filename, " w+b" )} ;
337333 // The value at each offset is the byte offset (e.g. byte 1 in the file has the value 0x01).
338334 for (uint8_t j = 0 ; j < 40 ; ++j) {
339- fwrite (&j, 1 , 1 , file) ;
335+ file << j ;
340336 }
341- rewind (file );
337+ file. rewind ();
342338
343339 // The buffer is 25 bytes, allow rewinding 10 bytes.
344- CBufferedFile bf (file, 25 , 10 , 222 , 333 );
340+ CBufferedFile bf (file. Get () , 25 , 10 , 222 , 333 );
345341
346342 uint8_t i;
347343 // This is like bf >> (7-byte-variable), in that it will cause data
@@ -386,16 +382,16 @@ BOOST_AUTO_TEST_CASE(streams_buffered_file_rand)
386382
387383 fs::path streams_test_filename = m_args.GetDataDirBase () / " streams_test_tmp" ;
388384 for (int rep = 0 ; rep < 50 ; ++rep) {
389- FILE* file = fsbridge::fopen (streams_test_filename, " w+b" );
385+ AutoFile file{ fsbridge::fopen (streams_test_filename, " w+b" )} ;
390386 size_t fileSize = InsecureRandRange (256 );
391387 for (uint8_t i = 0 ; i < fileSize; ++i) {
392- fwrite (&i, 1 , 1 , file) ;
388+ file << i ;
393389 }
394- rewind (file );
390+ file. rewind ();
395391
396392 size_t bufSize = InsecureRandRange (300 ) + 1 ;
397393 size_t rewindSize = InsecureRandRange (bufSize);
398- CBufferedFile bf (file, bufSize, rewindSize, 222 , 333 );
394+ CBufferedFile bf (file. Get () , bufSize, rewindSize, 222 , 333 );
399395 size_t currentPos = 0 ;
400396 size_t maxPos = 0 ;
401397 for (int step = 0 ; step < 100 ; ++step) {
0 commit comments