Add tests for axis letter

This commit is contained in:
Benoit Pasquier 2020-07-23 18:58:26 +10:00 committed by Simon Christ
parent 5cb7a8efb7
commit 255a32663e
2 changed files with 26 additions and 0 deletions

24
test/axis_letter.jl Normal file
View File

@ -0,0 +1,24 @@
@testset "axis letter" begin
using Plots, RecipesBase
# a custom type for dispacthing the axis-letter-testing recipe
struct MyType <: Number
val::Float64
end
value(m::MyType) = m.val
data = MyType.(sort(randn(20)))
# A recipe that puts the axis letter in the title
@recipe function f(::Type{T}, m::T) where T <: AbstractArray{<:MyType}
title --> string(plotattributes[:letter])
value.(m)
end
@testset "$f (orientation = $o)" for f in [histogram, barhist, stephist, scatterhist], o in [:vertical, :horizontal]
@test f(data, orientation=o).subplots[1].attr[:title] == (o == :vertical ? "x" : "y")
end
@testset "$f" for f in [hline, hspan]
@test f(data).subplots[1].attr[:title] == "y"
end
@testset "$f" for f in [vline, vspan]
@test f(data).subplots[1].attr[:title] == "x"
end
end

View File

@ -9,8 +9,10 @@ using Gtk
using LibGit2
import GeometryTypes, GeometryBasics
using Dates
using RecipesBase
include("test_axes.jl")
include("axis_letter.jl")
include("test_recipes.jl")
include("test_hdf5plots.jl")
include("test_pgfplotsx.jl")