Skip to content

Commit

Permalink
fix deprecations (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
bicycle1885 authored Mar 24, 2018
1 parent 32c01b1 commit 86dcf65
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
julia 0.6
Compat 0.62
TranscodingStreams 0.3
1 change: 1 addition & 0 deletions src/CodecXz.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export
XzDecompressor,
XzDecompressorStream

using Compat: Cvoid
import TranscodingStreams:
TranscodingStreams,
TranscodingStream,
Expand Down
8 changes: 4 additions & 4 deletions src/liblzma.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ mutable struct LZMAStream
avail_out::Csize_t
total_out::UInt64

allocator::Ptr{Void}
allocator::Ptr{Cvoid}

internal::Ptr{Void}
internal::Ptr{Cvoid}

reserved_ptr::NTuple{4,Ptr{Void}}
reserved_ptr::NTuple{4,Ptr{Cvoid}}
reserved_uint::NTuple{2,UInt64}
reserved_size::NTuple{2,Csize_t}
reserved_enum::NTuple{2,Cint}
Expand Down Expand Up @@ -100,5 +100,5 @@ function code(stream::LZMAStream, action::Integer)
end

function free(stream::LZMAStream)
ccall((:lzma_end, liblzma), Void, (Ref{LZMAStream},), stream)
ccall((:lzma_end, liblzma), Cvoid, (Ref{LZMAStream},), stream)
end
13 changes: 9 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
using CodecXz
using Base.Test
if VERSION < v"0.7-"
using Base.Test
else
using Test
end
using Compat
import TranscodingStreams

@testset "Xz Codec" begin
codec = XzCompressor()
@test codec isa XzCompressor
@test ismatch(r"^CodecXz.XzCompressor\(level=\d, check=\d+\)$", sprint(show, codec))
@test occursin(r"^(CodecXz\.)?XzCompressor\(level=\d, check=\d+\)$", sprint(show, codec))
@test CodecXz.initialize(codec) === nothing
@test CodecXz.finalize(codec) === nothing

codec = XzDecompressor()
@test codec isa XzDecompressor
@test ismatch(r"^CodecXz.XzDecompressor\(memlimit=\d+, flags=\d+\)$", sprint(show, codec))
@test occursin(r"^(CodecXz\.)?XzDecompressor\(memlimit=\d+, flags=\d+\)$", sprint(show, codec))
@test CodecXz.initialize(codec) === nothing
@test CodecXz.finalize(codec) === nothing

# Generated by `lzma.compress(b"foo")` on CPython 3.5.2.
data = b"\xfd7zXZ\x00\x00\x04\xe6\xd6\xb4F\x02\x00!\x01\x16\x00\x00\x00t/\xe5\xa3\x01\x00\x02foo\x00\x00X\x15\xa9{,\xe6,\x98\x00\x01\x1b\x03\x0b/\xb9\x10\x1f\xb6\xf3}\x01\x00\x00\x00\x00\x04YZ"
data = Vector(b"\xfd7zXZ\x00\x00\x04\xe6\xd6\xb4F\x02\x00!\x01\x16\x00\x00\x00t/\xe5\xa3\x01\x00\x02foo\x00\x00X\x15\xa9{,\xe6,\x98\x00\x01\x1b\x03\x0b/\xb9\x10\x1f\xb6\xf3}\x01\x00\x00\x00\x00\x04YZ")
@test read(XzDecompressorStream(IOBuffer(data))) == b"foo"
@test read(XzDecompressorStream(IOBuffer(vcat(data, data)))) == b"foofoo"
# corrupt data
Expand Down

0 comments on commit 86dcf65

Please sign in to comment.