Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nhz2 committed Mar 30, 2024
1 parent f7b9a9d commit 13dec86
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 5 additions & 1 deletion ext/TestExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,15 @@ function TranscodingStreams.test_chunked_read(Encoder, Decoder)
ok = true
for chunk in chunks
stream = TranscodingStream(Decoder(), buffer, stop_on_end=true)
ok &= hash(read(stream)) == hash(chunk)
ok &= read(stream) == chunk
ok &= eof(stream)
ok &= isreadable(stream)
close(stream)
end
# read without stop_on_end should read the full data.
stream = TranscodingStream(Decoder(), IOBuffer(data))
ok &= read(stream) == reduce(vcat, chunks)
close(stream)
Test.@test ok
end
finalize(encoder)
Expand Down
10 changes: 6 additions & 4 deletions test/codecnoop.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,18 @@
data = collect(0x00:0x0f)
stream = TranscodingStream(Noop(), IOBuffer(data))
@test !ismarked(stream)
mark(stream)
@test mark(stream) == 0
@test ismarked(stream)
@test [read(stream, UInt8) for _ in 1:3] == data[1:3]
reset(stream)
@test reset(stream) == 0
@test_throws ArgumentError reset(stream)
@test !ismarked(stream)
@test [read(stream, UInt8) for _ in 1:3] == data[1:3]
mark(stream)
@test mark(stream) == 3
@test ismarked(stream)
unmark(stream)
@test unmark(stream)
@test !ismarked(stream)
@test !unmark(stream)
close(stream)

stream = TranscodingStream(Noop(), IOBuffer(b"foobarbaz"))
Expand Down

0 comments on commit 13dec86

Please sign in to comment.