Skip to content

Commit

Permalink
test seekstart deletes data
Browse files Browse the repository at this point in the history
  • Loading branch information
nhz2 committed Oct 16, 2023
1 parent 1cb583d commit 7961e40
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/codecnoop.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 16 additions & 0 deletions test/codecquadruple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7961e40

Please sign in to comment.