Skip to content

Commit

Permalink
Merge pull request #13 from JuliaImages/coverage
Browse files Browse the repository at this point in the history
Adds more tests for code coverage
  • Loading branch information
zygmuntszpak authored Dec 2, 2020
2 parents f95a00f + 0aedf22 commit 67deb2a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/algorithms/canny.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@
end
end

@testset "Default Values" begin
img = Gray{N0f8}.(load("algorithms/References/circle.png"))
out, offsets = detect_subpixel_edges(img)
@test_reference "References/circle_edge.png" Gray.(detect_edges(img)) by=edge_detection_equality()
@test_reference "References/circle_edge.png" Gray.(out) by=edge_detection_equality()
end

@testset "Numerical" begin
# Check that the image only has ones or zeros.
img = Gray{N0f8}.(load("algorithms/References/circle.png"))
Expand Down
19 changes: 19 additions & 0 deletions test/algorithms/gradient_orientation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,23 @@
out = detect_gradient_orientation(g₁, g₂)
@test all(out .== deg2rad.([90.0, 135.0, 180.0, 225.0, 270.0, 315.0, 0.0, 45.0]))
end

@testset "Undefined Angles" begin
# When the gradient magnitude is close to zero the gradient orientation
# is undefined and we return a "sentinel" value of 360 degrees or
# 2π.
out₁ = detect_gradient_orientation([0.0], [0.0], OrientationConvention(in_radians = false))
out₂ = detect_gradient_orientation([0.0], [0.0], OrientationConvention(in_radians = true))
@test out₁ == [360]
@test out₂ == [2π]

detect_gradient_orientation!(out₂, [0.0], [0.0])
@test out₂ == [2π]
end

@testset "Warning" begin
convention = OrientationConvention(compass_direction = 'X')
@test_logs (:warn, "Unrecognised compass_direction... using a default direction of south (S).") detect_gradient_orientation([0.0], [0.0], convention)
end

end

2 comments on commit 67deb2a

@zygmuntszpak
Copy link
Member 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/25659

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.0 -m "<description of version>" 67deb2a39a9d4119a164f920be32c9730a26afee
git push origin v0.1.0

Please sign in to comment.