Skip to content

Commit

Permalink
Switch from MutatePlainDataArray to Setfield for tests (#35)
Browse files Browse the repository at this point in the history
* update test dependencies

* fix typo

* remove unzip_jll
  • Loading branch information
nhz2 authored Nov 14, 2023
1 parent 9e8c54f commit 5d895f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193"
LibArchive_jll = "1e303b3e-d4db-56ce-88c4-91e52606a1a8"
Mmap = "a63ad114-7e13-5084-954f-fe012c677804"
MutatePlainDataArray = "3b0f367b-da20-4531-811a-c13cc92422b5"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TranscodingStreams = "3bb67fe8-82b1-5028-8e26-92a6c54297fa"
ZipArchives = "49080126-0e18-4c2a-b176-c102e4b3760c"
Expand Down
9 changes: 5 additions & 4 deletions test/test_reader.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include("common.jl")
using Pkg.Artifacts: @artifact_str, ensure_artifact_installed
using Base64: base64decode
using MutatePlainDataArray: aref
using Setfield: @set
using p7zip_jll: p7zip_jll

@testset "find_end_of_central_directory_record unit tests" begin
Expand Down Expand Up @@ -253,17 +253,18 @@ end

# now try with a bad uncompressed_size
r = ZipBufferReader(read(joinpath(artifact"fixture", "fixture", "ubuntu22-7zip.zip")))
aref(r.entries)[1].uncompressed_size[] = 2
correct_entry = r.entries[1]
r.entries[1] = @set(correct_entry.uncompressed_size = 2)
@test_throws ArgumentError zip_test_entry(r, 1)
@test_throws ArgumentError zip_readentry(r, 1)

# now try with a bad uncompressed_size
r = ZipBufferReader(read(joinpath(artifact"fixture", "fixture", "ubuntu22-7zip.zip")))
aref(r.entries)[1].uncompressed_size[] = typemax(Int64)-1
r.entries[1] = @set(correct_entry.uncompressed_size = typemax(Int64)-1)
@test_throws ArgumentError zip_test_entry(r, 1)
# @test_throws OutOfMemoryError zip_readentry(r, 1)

aref(r.entries)[1].uncompressed_size[] = 1<<30
r.entries[1] = @set(correct_entry.uncompressed_size = 1<<30)
@test_throws ArgumentError zip_test_entry(r, 1)
@test_throws ArgumentError zip_readentry(r, 1)

Expand Down

0 comments on commit 5d895f4

Please sign in to comment.