Skip to content

Commit

Permalink
Add tests for pledgeinsize
Browse files Browse the repository at this point in the history
  • Loading branch information
nhz2 committed Oct 5, 2024
1 parent 04e818f commit e0c0238
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/Downstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
Pkg.Registry.update()
Pkg.activate(;temp=true)
# force it to use this PR's version of the package
ENV["JULIA_PKG_DEVDIR"]= mktempdir()
Pkg.develop([
PackageSpec(path="."),
PackageSpec(name="${{ matrix.package }}"),
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/Upstream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Upstream
on:
push:
branches: [master]
tags: [v*]
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: 1
arch: x64
- uses: julia-actions/julia-buildpkg@latest
- name: Load the upstream packages and run the tests
shell: julia --color=yes {0}
run: |
using Pkg
Pkg.Registry.update()
Pkg.activate(;temp=true)
# force it to use this PR's version of the package
ENV["JULIA_PKG_DEVDIR"]= mktempdir()
Pkg.develop([
PackageSpec(path="."),
PackageSpec(name="TranscodingStreams"),
])
Pkg.update()
Pkg.test("CodecZstd")
27 changes: 25 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,17 @@ include("utils.jl")
@test CodecZstd.find_decompressed_size(v) == 22

codec = ZstdCompressor
buffer3 = transcode(codec, b"Hello")
buffer4 = transcode(codec, b"World!")
sink = IOBuffer()
s = TranscodingStream(codec(), sink; stop_on_end=true)
write(s, b"Hello")
close(s)
buffer3 = take!(sink)
@test CodecZstd.find_decompressed_size(buffer3) == CodecZstd.ZSTD_CONTENTSIZE_UNKNOWN
sink = IOBuffer()
s = TranscodingStream(codec(), sink; stop_on_end=true)
write(s, b"Hello")
close(s)
buffer4 = take!(sink)
@test CodecZstd.find_decompressed_size(buffer4) == CodecZstd.ZSTD_CONTENTSIZE_UNKNOWN

write(iob, buffer1)
Expand All @@ -156,6 +164,21 @@ include("utils.jl")
@test CodecZstd.find_decompressed_size(v) == CodecZstd.ZSTD_CONTENTSIZE_ERROR
end

@testset "pledgeinsize" begin
if isdefined(TranscodingStreams, :pledgeinsize)
# when pledgeinsize is available transcode should save the
# decompressed size in a header
for n in [0:30; 1000; 1000000; 10000000;]
a = transcode(ZstdCompressor, rand(UInt8, n))
@test CodecZstd.find_decompressed_size(a) == n
a = transcode(ZstdCompressor, rand(0x00:0x01, n))
@test CodecZstd.find_decompressed_size(a) == n
a = transcode(ZstdCompressor, zeros(UInt8, n))
@test CodecZstd.find_decompressed_size(a) == n
end
end
end

include("compress_endOp.jl")
include("static_only_tests.jl")

Expand Down

0 comments on commit e0c0238

Please sign in to comment.