Skip to content

Commit

Permalink
Add show test for MIME type tab-separated-values (#34766)
Browse files Browse the repository at this point in the history
  • Loading branch information
kczimm authored and KristofferC committed Apr 11, 2020
1 parent 4d9806b commit 77dadd8
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions stdlib/DelimitedFiles/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ end

@testset "show with MIME types" begin
@test sprint(show, "text/csv", [1 2; 3 4]) == "1,2\n3,4\n"
@test sprint(show, "text/tab-separated-values", [1 2; 3 4]) == "1\t2\n3\t4\n"

for writefunc in ((io,x) -> show(io, "text/csv", x),
(io,x) -> invoke(writedlm, Tuple{IO,Any,Any}, io, x, ","))
Expand All @@ -266,6 +267,23 @@ end
@test vec(readdlm(io, ',')) == x
end
end

for writefunc in ((io,x) -> show(io, "text/tab-separated-values", x),
(io,x) -> invoke(writedlm, Tuple{IO,Any,Any}, io, x, "\t"))
# iterable collections of iterable rows:
let x = [(1,2), (3,4)], io = IOBuffer()
writefunc(io, x)
seek(io, 0)
@test readdlm(io, '\t') == [1 2; 3 4]
end
# vectors of strings:
let x = ["foo", "bar"], io = IOBuffer()
writefunc(io, x)
seek(io, 0)
@test vec(readdlm(io, '\t')) == x
end
end

end

# Test that we can read a write protected file
Expand Down

0 comments on commit 77dadd8

Please sign in to comment.