Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tests for FileIO interface #9

Merged
merged 1 commit into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/fileio_interface.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fileio_load(f::File{format"WebP"}; kwargs...) = decode(f.filename; kwargs...)
fileio_load(f::File{format"WebP"}; kwargs...) = read_webp(f.filename; kwargs...)

function fileio_save(f::File{format"WebP"}, image::AbstractMatrix{<:Colorant}; kwargs...)
return write_webp(f.filename, image; kwargs...)
Expand Down
25 changes: 25 additions & 0 deletions test/fileio_interface_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using FileIO
using Test
using TestImages
using WebP

@testset "FileIO interface" begin
expected_image = testimage("lighthouse")

mktempdir() do tmp_dir_path
file_path = joinpath(tmp_dir_path, "lighthouse.webp")
f = File{format"WebP"}(file_path)
WebP.write_webp(file_path, expected_image)

@testset "fileio_load" begin
image = WebP.fileio_load(f)
@test size(image) == size(expected_image)
end

@testset "fileio_save" begin
WebP.fileio_save(f, expected_image)
image = WebP.read_webp(file_path)
@test size(image) == size(expected_image)
end
end
end
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ using Test
@testset "WebP.jl" begin
include(joinpath(@__DIR__, "decoding_tests.jl"))
include(joinpath(@__DIR__, "encoding_tests.jl"))
include(joinpath(@__DIR__, "fileio_interface_tests.jl"))
end
Loading