@@ -81,24 +81,26 @@ function TranscodingStreams.test_chunked_read(Encoder, Decoder)
81
81
alpha = b " 色即是空"
82
82
encoder = Encoder ()
83
83
initialize (encoder)
84
- for _ in 1 : 500
85
- chunks = [rand (alpha, rand (0 : 100 )) for _ in 1 : rand (1 : 100 )]
86
- data = mapfoldl (x-> transcode (encoder, x), vcat, chunks, init= UInt8[])
87
- buffer = NoopStream (IOBuffer (data))
88
- ok = true
89
- for chunk in chunks
90
- stream = TranscodingStream (Decoder (), buffer, stop_on_end= true )
91
- ok &= read (stream) == chunk
92
- ok &= position (stream) == length (chunk)
93
- ok &= eof (stream)
94
- ok &= isreadable (stream)
84
+ for sharedbuf in false : true
85
+ for _ in 1 : 500
86
+ chunks = [rand (alpha, rand (0 : 100 )) for _ in 1 : rand (1 : 100 )]
87
+ data = mapfoldl (x-> transcode (encoder, x), vcat, chunks, init= UInt8[])
88
+ buffer = NoopStream (IOBuffer (data))
89
+ ok = true
90
+ for chunk in chunks
91
+ stream = TranscodingStream (Decoder (), buffer; stop_on_end= true , sharedbuf)
92
+ ok &= read (stream) == chunk
93
+ ok &= position (stream) == length (chunk)
94
+ ok &= eof (stream)
95
+ ok &= isreadable (stream)
96
+ close (stream)
97
+ end
98
+ # read without stop_on_end should read the full data.
99
+ stream = TranscodingStream (Decoder (), IOBuffer (data))
100
+ ok &= read (stream) == reduce (vcat, chunks)
95
101
close (stream)
102
+ Test. @test ok
96
103
end
97
- # read without stop_on_end should read the full data.
98
- stream = TranscodingStream (Decoder (), IOBuffer (data))
99
- ok &= read (stream) == reduce (vcat, chunks)
100
- close (stream)
101
- Test. @test ok
102
104
end
103
105
finalize (encoder)
104
106
end
0 commit comments