Skip to content

Commit 6dc0270

Browse files
committed
add test_roundtrip_lines
1 parent dab0722 commit 6dc0270

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/testtools.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,19 @@ function test_roundtrip_transcode(encode, decode)
3131
Base.Test.@test hash(transcode(decode(), transcode(encode(), data))) == hash(data)
3232
end
3333
end
34+
35+
function test_roundtrip_lines(encoder, decoder)
36+
srand(12345)
37+
lines = String[]
38+
buf = IOBuffer()
39+
stream = encoder(buf)
40+
for i in 1:100_000
41+
line = randstring(rand(0:1000))
42+
println(stream, line)
43+
push!(lines, line)
44+
end
45+
write(stream, TOKEN_END)
46+
flush(stream)
47+
seekstart(buf)
48+
Base.Test.@test hash(lines) == hash(readlines(decoder(buf)))
49+
end

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ using Base.Test
8686

8787
TranscodingStreams.test_roundtrip_read(IdentityStream, IdentityStream)
8888
TranscodingStreams.test_roundtrip_write(IdentityStream, IdentityStream)
89+
TranscodingStreams.test_roundtrip_lines(IdentityStream, IdentityStream)
8990
end
9091

9192
for pkg in ["CodecZlib", "CodecBzip2", "CodecXz", "CodecZstd"]

0 commit comments

Comments
 (0)