Skip to content

Commit

Permalink
Fix test_roundtrip_write (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
nhz2 authored Jul 20, 2024
1 parent 76543ed commit 466b6d0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "TranscodingStreams"
uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa"
license = "MIT"
authors = ["Kenta Sato <bicycle1885@gmail.com>"]
version = "0.11.0"
version = "0.11.1"

[deps]
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand Down
19 changes: 15 additions & 4 deletions ext/TestExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,25 @@ function TranscodingStreams.test_roundtrip_read(encoder, decoder)
end
end

# flush all nested streams and return final data
function take_all(stream)
if stream isa Base.GenericIOBuffer
seekstart(stream)
read(stream)
else
write(stream, TranscodingStreams.TOKEN_END)
flush(stream)
take_all(stream.stream)
end
end

function TranscodingStreams.test_roundtrip_write(encoder, decoder)
seed!(TEST_RANDOM_SEED)
for n in vcat(0:30, sort!(rand(500:100_000, 30))), alpha in (0x00:0xff, 0x00:0x0f)
data = rand(alpha, n)
file = IOBuffer()
stream = encoder(decoder(file))
write(stream, data, TOKEN_END); flush(stream)
Test.@test hash(take!(file)) == hash(data)
stream = encoder(decoder(IOBuffer()))
write(stream, data)
Test.@test take_all(stream) == data
close(stream)
end
end
Expand Down

2 comments on commit 466b6d0

@nhz2
Copy link
Member Author

@nhz2 nhz2 commented on 466b6d0 Jul 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/111423

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.11.1 -m "<description of version>" 466b6d03e380b5a5bc79edcc7376af77037f2245
git push origin v0.11.1

Please sign in to comment.