From 13dec86bdd9c3759c03774872a81a4660fa3ee40 Mon Sep 17 00:00:00 2001 From: nhz2 Date: Sat, 30 Mar 2024 19:50:14 -0400 Subject: [PATCH] add more tests --- ext/TestExt.jl | 6 +++++- test/codecnoop.jl | 10 ++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ext/TestExt.jl b/ext/TestExt.jl index 71aa1226..b7c7de36 100644 --- a/ext/TestExt.jl +++ b/ext/TestExt.jl @@ -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) diff --git a/test/codecnoop.jl b/test/codecnoop.jl index 2acd28a7..5a9d371f 100644 --- a/test/codecnoop.jl +++ b/test/codecnoop.jl @@ -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"))