Skip to content

Commit 8392452

Browse files
committed
Add tests for mime save
1 parent 68b76f6 commit 8392452

File tree

6 files changed

+1002
-0
lines changed

6 files changed

+1002
-0
lines changed

test/files/mimesavetest.eps

Lines changed: 950 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/files/mimesavetest.pdf

19.8 KB
Binary file not shown.

test/files/mimesavetest.png

3.55 KB
Loading

test/files/mimesavetest.svg

Lines changed: 3 additions & 0 deletions
Loading

test/runtests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
using FileIO
22
using Base.Test
33

4+
immutable MimeSaveTestType
5+
end
6+
47
@testset "FileIO" begin
58
include("query.jl")
69
include("loadsave.jl")
710
include("error_handling.jl")
11+
include("test_mimesave.jl")
812
end

test/test_mimesave.jl

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using FileIO
2+
using Base.Test
3+
4+
@testset "Mime save" begin
5+
6+
function Base.show(io::IO, m::MIME"image/svg+xml", data::MimeSaveTestType)
7+
content = read(joinpath(@__DIR__, "files", "mimesavetest.svg"))
8+
write(io, content)
9+
end
10+
11+
function Base.show(io::IO, m::MIME"application/pdf", data::MimeSaveTestType)
12+
content = read(joinpath(@__DIR__, "files", "mimesavetest.pdf"))
13+
write(io, content)
14+
end
15+
16+
function Base.show(io::IO, m::MIME"application/eps", data::MimeSaveTestType)
17+
content = read(joinpath(@__DIR__, "files", "mimesavetest.eps"))
18+
write(io, content)
19+
end
20+
21+
function Base.show(io::IO, m::MIME"image/png", data::MimeSaveTestType)
22+
content = read(joinpath(@__DIR__, "files", "mimesavetest.png"))
23+
write(io, content)
24+
end
25+
26+
data = MimeSaveTestType()
27+
28+
output_filename = tempname()
29+
30+
for filetype in [".svg", ".pdf", ".eps", ".png"]
31+
32+
try
33+
save(output_filename * filetype, data)
34+
35+
content_original = read(joinpath(@__DIR__, "files", "mimesavetest$filetype"))
36+
content_new = read(output_filename * filetype)
37+
38+
@test content_new == content_original
39+
finally
40+
rm(output_filename * filetype)
41+
end
42+
43+
end
44+
45+
end

0 commit comments

Comments
 (0)