-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
95 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,6 @@ | |
/Manifest.toml | ||
fixture.tar.gz | ||
fixture | ||
/test/testdata/ | ||
.CondaPkg | ||
*.cov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[ziparchives-jl] | ||
git-tree-sha1 = "df9dada7b01ead92def5830def01103ea6923f53" | ||
|
||
[[ziparchives-jl.download]] | ||
sha256 = "99a9bb1d9cba1fae77fd7be224b654da1f247815845ef4ac682a546e8dc70ceb" | ||
url = "https://github.com/medyan-dev/ZipArchives.jl/releases/download/v2.1.6/fixture.tar.gz" | ||
|
||
[deflate64-rs] | ||
git-tree-sha1 = "3d6705eb6be762b7a849e06a7352f2a1872e222a" | ||
|
||
[[deflate64-rs.download]] | ||
sha256 = "c9d31151deac3eff8856e271c7fb8d2eb2c659d63830955a05c6a481d555d710" | ||
url = "https://github.com/anatawa12/deflate64-rs/archive/refs/tags/v0.1.9.tar.gz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using StableRNGs: StableRNG | ||
|
||
# This script will create a "testdata" directory | ||
# This directory can be compressed on windows to create | ||
# a test for deflate64 | ||
# To compress, open the directory in File Explorer | ||
# Then press ctrl A to select all the files. | ||
# Next right click, and press "Compress to ZIP file" button. | ||
|
||
rng = StableRNG(1234) | ||
|
||
rm("testdata"; recursive=true, force=true) | ||
dir = mkdir("testdata") | ||
|
||
write(joinpath(dir,"abig.dat"), zeros(UInt8, 2^31)) | ||
for i in 0:500 | ||
write(joinpath(dir,"small$(i).dat"), zeros(UInt8, i)) | ||
end | ||
|
||
thing = rand(rng, UInt8, 200) | ||
d = UInt8[] | ||
for dist in [0:258; 1000:1030; 2000:1000:33000; 34000:10000:100_000] | ||
append!(d, thing) | ||
append!(d, rand(rng, 0x00:0x0f, dist)) | ||
end | ||
write(joinpath(dir, "dist-rand.dat"), d) | ||
|
||
for n in 65536-300:65536-100 | ||
write(joinpath(dir, "dist-$(n).dat"), [thing; zeros(UInt8, n); thing]) | ||
end | ||
|
||
write(joinpath(dir, "incomp.dat"), rand(rng, UInt8, 400_000)) | ||
|
||
# Finally write this file | ||
write(joinpath(dir, "gen_files.jl"), read(@__FILE__)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,33 @@ | ||
#= | ||
These tests are ported from https://github.com/anatawa12/deflate64-rs | ||
https://github.com/anatawa12/deflate64-rs is licensed under MIT License: | ||
> The MIT License (MIT) | ||
> | ||
> Copyright (c) .NET Foundation and Contributors | ||
> Copyright (c) anatawa12 2023 | ||
> | ||
> All rights reserved. | ||
> | ||
> Permission is hereby granted, free of charge, to any person obtaining a copy | ||
> of this software and associated documentation files (the "Software"), to deal | ||
> in the Software without restriction, including without limitation the rights | ||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
> copies of the Software, and to permit persons to whom the Software is | ||
> furnished to do so, subject to the following conditions: | ||
> | ||
> The above copyright notice and this permission notice shall be included in all | ||
> copies or substantial portions of the Software. | ||
> | ||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
> SOFTWARE. | ||
=# | ||
using Pkg.Artifacts: @artifact_str, ensure_artifact_installed | ||
|
||
# These tests are ported from https://github.com/anatawa12/deflate64-rs/releases/tag/v0.1.9 | ||
|
||
include("utils.jl") | ||
|
||
#TODO Use custom errors for invalid deflate data. | ||
|
||
@testset "tests from deflate64-rs" begin | ||
ensure_artifact_installed("deflate64-rs", joinpath(@__DIR__,"Artifacts.toml")) | ||
test_assets = joinpath(artifact"deflate64-rs", "deflate64-rs-0.1.9", "test-assets") | ||
checkcrc32_zipfile(joinpath(test_assets,"deflate64.zip")) | ||
|
||
u = read(joinpath(test_assets,"issue-13/logo.png")) | ||
c = read(joinpath(test_assets,"issue-13/unitwf-1.5.0.minimized.zip"))[1183:1182+34919] | ||
@test de64compress(c) == u | ||
|
||
c = read(joinpath(test_assets,"issue-23/raw_deflate64_index_out_of_bounds")) | ||
@test_throws ErrorException("incomplete code table") de64compress(c) | ||
|
||
c = read(joinpath(test_assets,"issue-25/deflate64_not_enough_space.zip"))[31:end] | ||
@test_throws ErrorException("incomplete code table") de64compress(c) | ||
|
||
c = read(joinpath(test_assets,"issue-29/raw.zip"))[122:end] | ||
@test_throws ErrorException("incomplete code table") de64compress(c) | ||
|
||
c = read(joinpath(test_assets,"deflate64.zip"))[41:40+2669743] | ||
stream = Deflate64DecompressorStream(IOBuffer(c)) | ||
u = UInt8[] | ||
read!(stream, u) | ||
@test u == UInt8[] | ||
@test read(stream) == read(joinpath(test_assets,"folder/binary.wmv")) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters