Skip to content

Commit 61d9d5e

Browse files
committed
Merge branch 'hotfix/write'
2 parents 242392d + 7432dc0 commit 61d9d5e

3 files changed

Lines changed: 21 additions & 6 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Bedgraph"
22
uuid = "0bcc2ff6-69eb-520d-bede-0374fc5bd2fd"
33
authors = ["Ciarán O'Mara <Ciaran.OMara@utas.edu.au>"]
4-
version = "1.2.0"
4+
version = "1.2.1"
55

66
[compat]
77
julia = "0.7, 1"

src/writer.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"Write [`Record`](@ref)s to `IO` as string."
2-
function Base.write(io::IO, records::Union{Vector{Record}, <:AbstractVector{Record}}) #Note: catching non-isbits arrays and we assume the indexes have been bumpped and the open ends are correct.
2+
function Base.write(io::IO, records::Vector{Record}) #Note: catching non-isbits arrays and we assume the indexes have been bumpped and the open ends are correct.
33
for record in records
44
Base.write(io, record, '\n')
55
end

test/runtests.jl

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,21 +144,36 @@ end
144144
@test_nowarn mktemp() do path, io
145145
header = Bedgraph.generateBasicHeader(Bag.records)
146146
write(io, header, Bag.records)
147-
# @test readstring(Bag.file) == readstring(outputfile) # differnces in float representation, but otherwise hold the same information.
148-
#TODO: explicitly test that Bag.files hold the same information.
147+
148+
seekstart(io)
149+
@test Bag.records == read(io, Vector{Record})
149150
end
150151

152+
# Not able to capture write(::IO, ::AbstractVector).
153+
# @test_nowarn mktemp() do path, io
154+
# # test AbstractVector
155+
# records = view(Bag.records, 2:4)
156+
# header = Bedgraph.generateBasicHeader(records)
157+
# write(io, header, records)
158+
#
159+
# seekstart(io)
160+
# @test records == read(io, Vector{Record})
161+
# end
162+
151163
@test_nowarn mktemp() do path, io
152164
header = Bedgraph.generateBasicHeader("chr19", Bag.records[1].first, Bag.records[end].last, bump_forward=false)
153165
write(io, header, Bag.records)
154-
# @test readstring(Bag.file) == readstring(outputfile) # differnces in float representation, but otherwise hold the same information.
155-
#TODO: explicitly test that Bag.files hold the same information.
166+
167+
seekstart(io)
168+
@test Bag.records == read(io, Vector{Record})
156169
end
157170

158171
@test_nowarn mktempdir() do path
159172
outputfile = joinpath(path, "test.bedgraph")
160173
header = Bedgraph.generateBasicHeader(Bag.records)
161174
write(outputfile, header, Bag.records)
175+
176+
@test Bag.records == read(outputfile, Vector{Record})
162177
end
163178

164179
end #testset I/O

0 commit comments

Comments
 (0)