|
1 | 1 | using TextHeatmaps
|
| 2 | +using ColorSchemes |
| 3 | +using Colors |
| 4 | +using FixedPointNumbers |
| 5 | + |
2 | 6 | using Test
|
| 7 | +using ReferenceTests |
3 | 8 | using Aqua
|
4 | 9 |
|
5 | 10 | @testset "TextHeatmaps.jl" begin
|
6 | 11 | @testset "Aqua.jl" begin
|
7 | 12 | @info "Running Aqua.jl's auto quality assurance tests. These might print warnings from dependencies."
|
8 | 13 | Aqua.test_all(TextHeatmaps)
|
9 | 14 | end
|
| 15 | + @testset "Heatmap" begin |
| 16 | + words = ["Test", "TextHeatmaps"] |
| 17 | + val = [4.2, -1.0] |
| 18 | + |
| 19 | + cs = TextHeatmaps.seismic |
| 20 | + cmin = get(cs, 0) # red |
| 21 | + cmax = get(cs, 1) # blue |
| 22 | + |
| 23 | + # Test default ColorScheme seismic |
| 24 | + h = heatmap(val, words) |
| 25 | + @test h.colors[1] ≈ cmax |
| 26 | + @test h.colors[2] != cmin |
| 27 | + @test_reference "references/seismic_centered.txt" repr("text/plain", h) |
| 28 | + |
| 29 | + h = heatmap(val, words; rangescale=:extrema) |
| 30 | + @test h.colors[1] ≈ cmax |
| 31 | + @test h.colors[2] ≈ cmin |
| 32 | + @test_reference "references/seismic_extrema.txt" repr("text/plain", h) |
| 33 | + |
| 34 | + # Test other colorschemes |
| 35 | + cs = ColorSchemes.inferno |
| 36 | + h = heatmap(val, words; cs=cs, rangescale=:centered) |
| 37 | + @test_reference "references/inferno_centered.txt" repr("text/plain", h) |
| 38 | + h = heatmap(val, words; cs=cs, rangescale=:extrema) |
| 39 | + @test_reference "references/inferno_extrema.txt" repr("text/plain", h) |
| 40 | + |
| 41 | + # Test errors |
| 42 | + @test_throws ArgumentError heatmap(val, ["Test", "Text", "Heatmaps"]) |
| 43 | + # Test inner constructor |
| 44 | + @test_throws ArgumentError TextHeatmaps.TextHeatmap(val, words, [cmin, cmax, cmax]) |
| 45 | + end |
10 | 46 | end
|
0 commit comments