Skip to content

Commit

Permalink
add color tests
Browse files Browse the repository at this point in the history
  • Loading branch information
t-bltg committed Aug 19, 2021
1 parent 7d8dc95 commit 9145af8
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 5 deletions.
15 changes: 14 additions & 1 deletion test/tst_barplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ end
[2.244, 8.406, 11.92, 3.165],
title = "Relative sizes of cities",
xlabel = "population [in mil]",
color = 220, # 256 color yellow
color = :yellow,
border = :solid,
symb = '=',
width = 60
Expand All @@ -178,3 +178,16 @@ end
@io2str(print(IOContext(::IO, :color=>true), p))
)
end

@testset "colors" begin
p = barplot(["B","A"], [2,1], color=9)
test_ref(
"references/barplot/col1.txt",
@io2str(print(IOContext(::IO, :color=>true), p))
)
p = barplot(["B","A"], [2,1], color=(200,50,0))
test_ref(
"references/barplot/col2.txt",
@io2str(print(IOContext(::IO, :color=>true), p))
)
end
18 changes: 16 additions & 2 deletions test/tst_boxplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"references/boxplot/default_parameters.txt",
@io2str(show(IOContext(::IO, :color=>true), p))
)
p = @inferred boxplot("series1", [1,2,3,4,5], title = "Test", xlim = [-1,8], color = (0,0,255), width = 50, border = :solid, xlabel="foo")
p = @inferred boxplot("series1", [1,2,3,4,5], title = "Test", xlim = [-1,8], color = :blue, width = 50, border = :solid, xlabel="foo")
test_ref(
"references/boxplot/default_parameters.txt",
@io2str(show(IOContext(::IO, :color=>true), p))
Expand All @@ -41,7 +41,7 @@ end
end

@testset "multi-series" begin
p = @inferred boxplot(["one", "two"], [[1,2,3,4,5], [2,3,4,5,6,7,8,9]], title="Multi-series", xlabel="foo", color=11) # color 256 yellowish
p = @inferred boxplot(["one", "two"], [[1,2,3,4,5], [2,3,4,5,6,7,8,9]], title="Multi-series", xlabel="foo", color=:yellow)
test_ref(
"references/boxplot/multi1.txt",
@io2str(show(IOContext(::IO, :color=>true), p))
Expand All @@ -57,3 +57,17 @@ end
@io2str(show(IOContext(::IO, :color=>true), p))
)
end

@testset "colors" begin
p = @inferred boxplot(["one", "two"], [[1,2,3], [4,5,6]], color=214)
test_ref(
"references/boxplot/col1.txt",
@io2str(show(IOContext(::IO, :color=>true), p))
)

p = @inferred boxplot(["one", "two"], [[1,2,3], [4,5,6]], color=(187,0,187))
test_ref(
"references/boxplot/col2.txt",
@io2str(show(IOContext(::IO, :color=>true), p))
)
end
25 changes: 23 additions & 2 deletions test/tst_histogram.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ end
x,
title = "My Histogram",
xlabel = "Absolute Frequency",
color = (0,0,255),
color = :blue,
margin = 7,
padding = 3,
labels = false,
Expand Down Expand Up @@ -124,7 +124,7 @@ end
x,
title = "My Histogram",
xlabel = "Absolute Frequency",
color = (255,255,0),
color = :yellow,
border = :solid,
symb = '=',
width = 50
Expand All @@ -133,4 +133,25 @@ end
"references/histogram/parameters2.txt",
@io2str(print(IOContext(::IO, :color=>true), p))
)

# colors
p = @inferred histogram(
x,
title = "Gray color",
color = 240,
)
test_ref(
"references/histogram/col1.txt",
@io2str(print(IOContext(::IO, :color=>true), p))
)

p = @inferred histogram(
x,
title = "Green color",
color = (50,100,50),
)
test_ref(
"references/histogram/col2.txt",
@io2str(print(IOContext(::IO, :color=>true), p))
)
end

0 comments on commit 9145af8

Please sign in to comment.