diff --git a/test/codecnoop.jl b/test/codecnoop.jl index 08eb696e..1656773f 100644 --- a/test/codecnoop.jl +++ b/test/codecnoop.jl @@ -333,4 +333,20 @@ end end end + + @testset "seekstart doesn't delete data" begin + sink = IOBuffer() + stream = NoopStream(sink, bufsize=16) + write(stream, "x") + # seekstart must not delete user data even if it errors. + try + seekstart(stream) + catch e + e isa ArgumentError || rethrow() + end + write(stream, TranscodingStreams.TOKEN_END) + flush(stream) + @test_broken take!(sink) == b"x" + close(stream) + end end diff --git a/test/codecquadruple.jl b/test/codecquadruple.jl index d753d01c..18a40753 100644 --- a/test/codecquadruple.jl +++ b/test/codecquadruple.jl @@ -107,4 +107,20 @@ end end end end + + @testset "seekstart doesn't delete data" begin + sink = IOBuffer() + stream = TranscodingStream(QuadrupleCodec(), sink, bufsize=16) + write(stream, "x") + # seekstart must not delete user data even if it errors. + try + seekstart(stream) + catch e + e isa ArgumentError || rethrow() + end + write(stream, TranscodingStreams.TOKEN_END) + flush(stream) + @test_broken take!(sink) == b"xxxx" + close(stream) + end end