Merge pull request #3182 from ThatcherC/component-tests
WIP: Units Tests and Code Coverage for src/components.jl
This commit is contained in:
commit
4c95ca5089
@ -31,6 +31,7 @@ end # testset
|
|||||||
include("test_defaults.jl")
|
include("test_defaults.jl")
|
||||||
include("test_axes.jl")
|
include("test_axes.jl")
|
||||||
include("test_axis_letter.jl")
|
include("test_axis_letter.jl")
|
||||||
|
include("test_components.jl")
|
||||||
include("test_recipes.jl")
|
include("test_recipes.jl")
|
||||||
include("test_hdf5plots.jl")
|
include("test_hdf5plots.jl")
|
||||||
include("test_pgfplotsx.jl")
|
include("test_pgfplotsx.jl")
|
||||||
|
|||||||
46
test/test_components.jl
Normal file
46
test/test_components.jl
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
using Plots, Test
|
||||||
|
|
||||||
|
@testset "Shape Copy" begin
|
||||||
|
square = Shape([(0,0),(1,0),(1,1),(0,1)])
|
||||||
|
square2 = Shape(square)
|
||||||
|
@test square2.x == square.x
|
||||||
|
@test square2.y == square.y
|
||||||
|
end
|
||||||
|
|
||||||
|
@testset "Shape Center" begin
|
||||||
|
square = Shape([(0,0),(1,0),(1,1),(0,1)])
|
||||||
|
@test Plots.center(square) == (0.5,0.5)
|
||||||
|
end
|
||||||
|
|
||||||
|
@testset "Shape Translate" begin
|
||||||
|
square = Shape([(0,0),(1,0),(1,1),(0,1)])
|
||||||
|
squareUp = Shape([(0,1),(1,1),(1,2),(0,2)])
|
||||||
|
squareUpRight = Shape([(1,1),(2,1),(2,2),(1,2)])
|
||||||
|
|
||||||
|
@test Plots.translate(square,0,1).x == squareUp.x
|
||||||
|
@test Plots.translate(square,0,1).y == squareUp.y
|
||||||
|
|
||||||
|
@test Plots.center(translate!(square,1)) == (1.5,1.5)
|
||||||
|
end
|
||||||
|
|
||||||
|
@testset "Brush" begin
|
||||||
|
@testset "Colors" begin
|
||||||
|
baseline = brush(1, RGB(0,0,0))
|
||||||
|
@test brush(:black) == baseline
|
||||||
|
@test brush("black") == baseline
|
||||||
|
end
|
||||||
|
@testset "Weight" begin
|
||||||
|
@test brush(10).size == 10
|
||||||
|
@test brush(0.1).size == 1
|
||||||
|
end
|
||||||
|
@testset "Alpha" begin
|
||||||
|
@test brush(0.4).alpha == 0.4
|
||||||
|
@test brush(20).alpha == nothing
|
||||||
|
end
|
||||||
|
@testset "Bad Argument" begin
|
||||||
|
# using test_logs because test_warn seems to not work anymore
|
||||||
|
@test_logs (:warn,"Unused brush arg: nothing (Nothing)") begin
|
||||||
|
brush(nothing)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
x
Reference in New Issue
Block a user