Added some tests for shorthands.jl

This commit is contained in:
Thatcher Chamberlin 2020-12-07 20:00:55 -05:00
parent e57a9349f6
commit 0e73bcdc4e
2 changed files with 49 additions and 0 deletions

View File

@ -32,6 +32,7 @@ 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_components.jl")
include("test_shorthands.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")

48
test/test_shorthands.jl Normal file
View File

@ -0,0 +1,48 @@
using Plots, Test
@testset "Shorthands" begin
@testset "Set Lims" begin
p = plot(rand(10))
xlims!((1,20))
@test xlims(p) == (1,20)
ylims!((-1,1))
@test ylims(p) == (-1,1)
zlims!((-1,1))
@test zlims(p) == (-1,1)
xlims!(-1,11)
@test xlims(p) == (-1,11)
ylims!((-10,10))
@test ylims(p) == (-10,10)
zlims!((-10,10))
@test zlims(p) == (-10,10)
end
@testset "Set Ticks" begin
p = plot([0,2,3,4,5,6,7,8,9,10])
xticks = 2:6
xticks!(xticks)
@test Plots.get_subplot(current(),1).attr[:xaxis][:ticks] == xticks
yticks = 0.2:0.1:0.7
yticks!(yticks)
@test Plots.get_subplot(current(),1).attr[:yaxis][:ticks] == yticks
xticks = [5,6,7.5]
xlabels = ["a","b","c"]
xticks!(xticks, xlabels)
@test Plots.get_subplot(current(),1).attr[:xaxis][:ticks] == (xticks, xlabels)
yticks = [.5,.6,.75]
ylabels = ["z","y","x"]
yticks!(yticks, ylabels)
@test Plots.get_subplot(current(),1).attr[:yaxis][:ticks] == (yticks, ylabels)
end
end