Skip to content

Commit

Permalink
Merge pull request #26 from hyrodium/feature/test_error
Browse files Browse the repository at this point in the history
Add test for ErrorException
  • Loading branch information
hyrodium authored Jun 19, 2021
2 parents efeff8d + e321be0 commit 0379936
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
5 changes: 3 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ImageClipboard"
uuid = "6db54171-f50f-4661-a74f-bc514ef16cee"
authors = ["hyrodium <hyrodium@gmail.com> and contributors"]
version = "0.1.0"
version = "0.1.1"

[deps]
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
Expand All @@ -17,6 +17,7 @@ ImageIO = "0.5"
[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[targets]
test = ["Test", "Images"]
test = ["Test", "Images", "InteractiveUtils"]
10 changes: 7 additions & 3 deletions src/_xclip.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ function _xclip()

# Pipe clipboard image to buffer
if success(pipeline(`xclip -selection clipboard -t image/png -o`; stdout=img_buf))
# Load image from buffer
img = load(img_buf)
return img
try
# Load image from buffer
img = load(img_buf)
return img
catch
error("No image in clipboard")
end
else
error("No image in clipboard")
end
Expand Down
10 changes: 8 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using ImageClipboard
using Images
using Test
using InteractiveUtils

@testset "ImageClipboard.jl" begin

Expand All @@ -9,7 +10,7 @@ using Test
clipboard_img(img)
img2 = clipboard_img()

# FIXME, windows..
# FIXME, windows exception (#10)
if Sys.iswindows()
@test RGBA.(img) == img2
else
Expand All @@ -22,10 +23,15 @@ using Test
clipboard_img(img)
img2 = clipboard_img()

# FIXME, windows..
# FIXME, windows exception (#10)
if !Sys.iswindows()
@test img == img2
end
end

@testset "Error if no image" begin
clipboard("")
@test_throws ErrorException("No image in clipboard") clipboard_img()
end

end

2 comments on commit 0379936

@hyrodium
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/39166

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.1 -m "<description of version>" 0379936dc24e2da0ed575c2b8b91c04d8366d363
git push origin v0.1.1

Please sign in to comment.