|
274 | 274 | @test !iswritable(stream)
|
275 | 275 | end
|
276 | 276 |
|
277 |
| - stream = NoopStream(IOBuffer("")) |
278 |
| - @test TranscodingStreams.unread(stream, b"foo") === nothing |
279 |
| - @test read(stream, 3) == b"foo" |
280 |
| - close(stream) |
| 277 | + @testset "unread" begin |
| 278 | + stream = NoopStream(IOBuffer("")) |
| 279 | + @test TranscodingStreams.unread(stream, b"foo") === nothing |
| 280 | + @test read(stream, 3) == b"foo" |
| 281 | + close(stream) |
281 | 282 |
|
282 |
| - stream = NoopStream(IOBuffer("foo")) |
283 |
| - @test read(stream, 3) == b"foo" |
284 |
| - @test TranscodingStreams.unread(stream, b"bar") === nothing |
285 |
| - @test read(stream, 3) == b"bar" |
286 |
| - close(stream) |
| 283 | + stream = NoopStream(IOBuffer("foo")) |
| 284 | + @test read(stream, 3) == b"foo" |
| 285 | + @test TranscodingStreams.unread(stream, b"bar") === nothing |
| 286 | + @test read(stream, 3) == b"bar" |
| 287 | + close(stream) |
287 | 288 |
|
288 |
| - stream = NoopStream(IOBuffer("foobar")) |
289 |
| - @test TranscodingStreams.unread(stream, b"baz") === nothing |
290 |
| - @test read(stream, 3) == b"baz" |
291 |
| - @test read(stream, 3) == b"foo" |
292 |
| - @test read(stream, 3) == b"bar" |
293 |
| - @test eof(stream) |
294 |
| - close(stream) |
| 289 | + stream = NoopStream(IOBuffer("foobar")) |
| 290 | + @test TranscodingStreams.unread(stream, b"baz") === nothing |
| 291 | + @test read(stream, 3) == b"baz" |
| 292 | + @test read(stream, 3) == b"foo" |
| 293 | + @test read(stream, 3) == b"bar" |
| 294 | + @test eof(stream) |
| 295 | + close(stream) |
295 | 296 |
|
296 |
| - stream = NoopStream(IOBuffer("foobar")) |
297 |
| - @test read(stream, 3) == b"foo" |
298 |
| - @test TranscodingStreams.unread(stream, b"baz") === nothing |
299 |
| - @test read(stream, 3) == b"baz" |
300 |
| - @test read(stream, 3) == b"bar" |
301 |
| - @test eof(stream) |
302 |
| - close(stream) |
| 297 | + stream = NoopStream(IOBuffer("foobar")) |
| 298 | + @test read(stream, 3) == b"foo" |
| 299 | + @test TranscodingStreams.unread(stream, b"baz") === nothing |
| 300 | + @test read(stream, 3) == b"baz" |
| 301 | + @test read(stream, 3) == b"bar" |
| 302 | + @test eof(stream) |
| 303 | + close(stream) |
303 | 304 |
|
304 |
| - stream = NoopStream(IOBuffer("foobar")) |
305 |
| - @test read(stream, 3) == b"foo" |
306 |
| - @test read(stream, 3) == b"bar" |
307 |
| - @test TranscodingStreams.unread(stream, b"baz") === nothing |
308 |
| - @test read(stream, 3) == b"baz" |
309 |
| - @test eof(stream) |
310 |
| - close(stream) |
| 305 | + stream = NoopStream(IOBuffer("foobar")) |
| 306 | + @test read(stream, 3) == b"foo" |
| 307 | + @test read(stream, 3) == b"bar" |
| 308 | + @test TranscodingStreams.unread(stream, b"baz") === nothing |
| 309 | + @test read(stream, 3) == b"baz" |
| 310 | + @test eof(stream) |
| 311 | + close(stream) |
311 | 312 |
|
312 |
| - stream = NoopStream(IOBuffer("foobar")) |
313 |
| - @test_throws ArgumentError TranscodingStreams.unsafe_unread(stream, pointer(b"foo"), -1) |
314 |
| - close(stream) |
| 313 | + for bufsize in (1, 2, 3, 4, 100) |
| 314 | + for n in (1, 100) |
| 315 | + stream = NoopStream(IOBuffer("foo"^n*"bar"^n); bufsize) |
| 316 | + @test mark(stream) == 0 |
| 317 | + @test read(stream, 3n) == codeunits("foo"^n) |
| 318 | + @test read(stream, 3n) == codeunits("bar"^n) |
| 319 | + TranscodingStreams.unread(stream, codeunits("baz"^n)) |
| 320 | + @test reset(stream) == 0 |
| 321 | + @test read(stream, 3n) == codeunits("foo"^n) |
| 322 | + @test read(stream, 3n) == codeunits("baz"^n) |
| 323 | + @test eof(stream) |
| 324 | + close(stream) |
| 325 | + end |
| 326 | + end |
| 327 | + |
| 328 | + # unread before mark |
| 329 | + stream = NoopStream(IOBuffer("foobar"); bufsize=16) |
| 330 | + @test read(stream, String) == "foobar" |
| 331 | + mark(stream) |
| 332 | + for i in 1:100 |
| 333 | + TranscodingStreams.unread(stream, b"foo") |
| 334 | + end |
| 335 | + @test read(stream, String) == "foo"^100 |
| 336 | + @test reset(stream) == 6 |
| 337 | + @test eof(stream) |
| 338 | + |
| 339 | + stream = NoopStream(IOBuffer("foobar")) |
| 340 | + @test_throws ArgumentError TranscodingStreams.unsafe_unread(stream, pointer(b"foo"), -1) |
| 341 | + close(stream) |
| 342 | + end |
315 | 343 |
|
316 | 344 | stream = NoopStream(IOBuffer(""))
|
317 | 345 | unsafe_write(stream, C_NULL, 0)
|
|
0 commit comments