@@ -309,6 +309,51 @@ TEST(ReadSingleChar_bumpc1)
309
309
VERIFY_IS_FALSE (stream.is_open ());
310
310
}
311
311
312
+ TEST (SequentialReadWrite)
313
+ {
314
+ utility::string_t fname = U (" SequentialReadWrite.txt" );
315
+
316
+ auto ostreamBuf = OPEN_W<char >(fname).get ();
317
+
318
+ VERIFY_IS_TRUE (ostreamBuf.is_open ());
319
+
320
+ for (int i = 0 ; i < 1000 ; i++)
321
+ {
322
+ ostreamBuf.putc (i % 26 + ' a' );
323
+ ostreamBuf.putn (" ABCDEFGHIJ" , 10 );
324
+ }
325
+ ostreamBuf.close ().wait ();
326
+ VERIFY_IS_FALSE (ostreamBuf.is_open ());
327
+
328
+ auto istreamBuf = OPEN_R<char >(fname).get ();
329
+ std::vector<pplx::task<void >> t;
330
+
331
+ for (int k = 0 ; k < 2 ; k++)
332
+ {
333
+ for (int i = 0 ; i < 1000 ; i++)
334
+ {
335
+ t.push_back (istreamBuf.getc ().then ([i, this ](char c) {
336
+ VERIFY_ARE_EQUAL (i % 26 + ' a' , c);
337
+ }));
338
+ t.push_back (istreamBuf.bumpc ().then ([i, this ](char c) {
339
+ VERIFY_ARE_EQUAL (i % 26 + ' a' , c);
340
+ }));
341
+ char *buffer = new char [11 ];
342
+ t.push_back (istreamBuf.getn (buffer, 10 ).then ([=](size_t n) {
343
+ VERIFY_ARE_EQUAL (10u , n);
344
+ VERIFY_ARE_EQUAL (std::string (" ABCDEFGHIJ" ), std::string (buffer, 10 ));
345
+ delete[] buffer;
346
+ }));
347
+ }
348
+ istreamBuf.seekpos (0 , std::ios::in);
349
+ }
350
+ istreamBuf.close ().wait ();
351
+ VERIFY_IS_FALSE (istreamBuf.is_open ());
352
+ for (size_t i = 0 ; i < t.size (); i++)
353
+ t[i].wait ();
354
+ }
355
+
356
+
312
357
#ifdef _WIN32
313
358
TEST (ReadSingleChar_bumpcw)
314
359
{
0 commit comments