Skip to content

Commit

Permalink
Merge 7f2c29a into 7d0abe4
Browse files Browse the repository at this point in the history
  • Loading branch information
Keno committed May 16, 2016
2 parents 7d0abe4 + 7f2c29a commit 17f04c3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
julia 0.3
Compat 0.4.8
Compat 0.7.9
4 changes: 2 additions & 2 deletions src/GZip.jl
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ function readline(s::GZipStream)
while(true)
# since gzgets didn't return C_NULL, there must be a \0 in the buffer
eos = search(buf, '\0', pos)
if eos == 1 || buf[eos-1] == '\n'
if eos == 1 || buf[eos-1] == @compat UInt8('\n')
return bytestring(resize!(buf, eos-1))
end

Expand Down Expand Up @@ -463,7 +463,7 @@ function write{T}(s::GZipStream, a::Array{T})
invoke(write, (Any, Array), s, a)
end
end

write(s::GZipStream, a::Array{UInt8}) = gzwrite(s, pointer(a), sizeof(a))
write(s::GZipStream, p::Ptr, nb::Integer) = gzwrite(s, p, nb)

function write{T,N}(s::GZipStream, a::SubArray{T,N,Array})
Expand Down
15 changes: 8 additions & 7 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Compat
using Compat: readstring
using GZip
using Base.Test

Expand Down Expand Up @@ -29,7 +30,7 @@ try
# test_group("Compress Test1: gzip.jl")
##########################

data = open(readall, test_infile);
data = open(readstring, test_infile);

first_char = data[1]

Expand All @@ -41,25 +42,25 @@ try
@test_throws EOFError write(gzfile, data)

if test_gunzip
data2 = readall(`$gunzip -c $test_compressed`)
data2 = readstring(`$gunzip -c $test_compressed`)
@test data == data2
end

data3 = gzopen(readall, test_compressed)
data3 = gzopen(readstring, test_compressed)
@test data == data3

# Test gzfdio
raw_file = open(test_compressed, "r")
gzfile = gzdopen(fd(raw_file), "r")
data4 = readall(gzfile)
data4 = readstring(gzfile)
close(gzfile)
close(raw_file)
@test data == data4

# Test peek
gzfile = gzopen(test_compressed, "r")
@test peek(gzfile) == first_char
readall(gzfile)
@test peek(gzfile) == UInt(first_char)
readstring(gzfile)
@test peek(gzfile) == -1
close(gzfile)

Expand All @@ -70,7 +71,7 @@ try
close(raw_file)

@compat try
gzopen(readall, test_compressed)
gzopen(readstring, test_compressed)
throw(ErrorException("Expecting ArgumentError or similar"))
catch ex
@test typeof(ex) <: Union{ArgumentError,ZError,GZError} ||
Expand Down

0 comments on commit 17f04c3

Please sign in to comment.