@@ -325,13 +325,20 @@ using FillArrays: Zeros
325
325
@testset " unread" begin
326
326
stream = NoopStream (IOBuffer (" " ))
327
327
@test TranscodingStreams. unread (stream, b " foo" ) === nothing
328
+ @test position (stream) == - 3
328
329
@test read (stream, 3 ) == b " foo"
330
+ @test position (stream) == 0
331
+ @test eof (stream)
329
332
close (stream)
330
333
331
334
stream = NoopStream (IOBuffer (" foo" ))
332
335
@test read (stream, 3 ) == b " foo"
336
+ @test position (stream) == 3
333
337
@test TranscodingStreams. unread (stream, b " bar" ) === nothing
338
+ @test position (stream) == 0
334
339
@test read (stream, 3 ) == b " bar"
340
+ @test position (stream) == 3
341
+ @test eof (stream)
335
342
close (stream)
336
343
337
344
stream = NoopStream (IOBuffer (" foobar" ))
@@ -351,24 +358,36 @@ using FillArrays: Zeros
351
358
close (stream)
352
359
353
360
stream = NoopStream (IOBuffer (" foobar" ))
361
+ @test position (stream) == 0
354
362
@test read (stream, 3 ) == b " foo"
363
+ @test position (stream) == 3
355
364
@test read (stream, 3 ) == b " bar"
365
+ @test position (stream) == 6
356
366
@test TranscodingStreams. unread (stream, b " baz" ) === nothing
367
+ @test position (stream) == 3
357
368
@test read (stream, 3 ) == b " baz"
369
+ @test position (stream) == 6
358
370
@test eof (stream)
371
+ @test position (stream) == 6
359
372
close (stream)
360
373
361
374
for bufsize in (1 , 2 , 3 , 4 , 100 )
362
375
for n in (1 , 100 )
363
376
stream = NoopStream (IOBuffer (" foo" ^ n* " bar" ^ n); bufsize)
364
377
@test mark (stream) == 0
378
+ @test position (stream) == 0
365
379
@test read (stream, 3 n) == codeunits (" foo" ^ n)
366
380
@test read (stream, 3 n) == codeunits (" bar" ^ n)
381
+ @test position (stream) == 6 n
367
382
TranscodingStreams. unread (stream, codeunits (" baz" ^ n))
383
+ @test position (stream) == 3 n
368
384
@test reset (stream) == 0
385
+ @test position (stream) == 0
369
386
@test read (stream, 3 n) == codeunits (" foo" ^ n)
370
387
@test read (stream, 3 n) == codeunits (" baz" ^ n)
388
+ @test position (stream) == 6 n
371
389
@test eof (stream)
390
+ @test position (stream) == 6 n
372
391
close (stream)
373
392
end
374
393
end
@@ -414,6 +433,11 @@ using FillArrays: Zeros
414
433
end
415
434
@test read (stream, 3 ) == b " bar"
416
435
close (stream)
436
+
437
+ stream = NoopStream (IOBuffer ())
438
+ write (stream, b " foo" )
439
+ @test_throws ArgumentError TranscodingStreams. unread (stream, b " bar" )
440
+ close (stream)
417
441
end
418
442
419
443
stream = NoopStream (IOBuffer (" " ))
0 commit comments