From 255a32663ed74bef609948190847fea206b42084 Mon Sep 17 00:00:00 2001 From: Benoit Pasquier Date: Thu, 23 Jul 2020 18:58:26 +1000 Subject: [PATCH] Add tests for axis letter --- test/axis_letter.jl | 24 ++++++++++++++++++++++++ test/runtests.jl | 2 ++ 2 files changed, 26 insertions(+) create mode 100644 test/axis_letter.jl diff --git a/test/axis_letter.jl b/test/axis_letter.jl new file mode 100644 index 00000000..69bf35e4 --- /dev/null +++ b/test/axis_letter.jl @@ -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 \ No newline at end of file diff --git a/test/runtests.jl b/test/runtests.jl index 946f13fc..13ae2868 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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")