Skip to content

Commit

Permalink
make write/unsafe_write on iobuffer return signed like other io
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC committed Feb 14, 2017
1 parent cfbad5f commit 81d4bd5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion base/iobuffer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ end
function unsafe_write(to::AbstractIOBuffer, p::Ptr{UInt8}, nb::UInt)
ensureroom(to, nb)
ptr = (to.append ? to.size+1 : to.ptr)
written = min(nb, length(to.data) - ptr + 1)
written = Int(min(nb, length(to.data) - ptr + 1))
towrite = written
d = to.data
while towrite > 0
Expand Down
14 changes: 7 additions & 7 deletions test/iobuffer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ioslength(io::IOBuffer) = (io.seekable ? io.size : nb_available(io))
let io = IOBuffer()
@test eof(io)
@test_throws EOFError read(io,UInt8)
@test write(io,"abc") == 3
@test write(io,"abc") === 3
@test isreadable(io)
@test iswritable(io)
@test isopen(io)
Expand All @@ -29,7 +29,7 @@ truncate(io, 0)
truncate(io, 10)
@test position(io) == 0
@test all(io.data .== 0)
@test write(io,Int16[1,2,3,4,5,6]) == 12
@test write(io,Int16[1,2,3,4,5,6]) === 12
seek(io, 2)
truncate(io, 10)
@test ioslength(io) == 10
Expand All @@ -39,8 +39,8 @@ truncate(io, 0)
@test write(io,"boston\ncambridge\n") > 0
@test String(take!(io)) == "boston\ncambridge\n"
@test String(take!(io)) == ""
@test write(io, Complex{Float64}(0)) == 16
@test write(io, Rational{Int64}(1//2)) == 16
@test write(io, Complex{Float64}(0)) === 16
@test write(io, Rational{Int64}(1//2)) === 16
close(io)
@test_throws ArgumentError write(io,UInt8[0])
@test_throws ArgumentError seek(io,0)
Expand Down Expand Up @@ -115,11 +115,11 @@ write(io,[1,2,3])
@test ioslength(io) == 75
@test length(io.data) == 75
skip(io,1)
@test write(io,UInt8(104)) == 1
@test write(io,UInt8(104)) === 1
skip(io,3)
@test write(io,b"apples") == 3
@test write(io,b"apples") === 3
skip(io,71)
@test write(io,'y') == 1
@test write(io,'y') === 1
@test readstring(io) == "happy"
@test eof(io)
write(io,zeros(UInt8,73))
Expand Down

0 comments on commit 81d4bd5

Please sign in to comment.