|
1 | 1 | @testset "Not exported Interface" begin |
2 | | - @test supertype(ImageInTerminal.TermColor256) <: ImageInTerminal.TermColorDepth |
3 | | - @test supertype(ImageInTerminal.TermColor24bit) <: ImageInTerminal.TermColorDepth |
| 2 | + @test supertype(TermColor256) <: TermColorDepth |
| 3 | + @test supertype(TermColor24bit) <: TermColorDepth |
4 | 4 |
|
5 | 5 | # This tests if the mapping from RGB to the |
6 | 6 | # 256 ansi color codes is correct |
|
18 | 18 | r, g, b = red(col), green(col), blue(col) |
19 | 19 | ri, gi, bi = map(c->round(Int, 23c), (r, g, b)) |
20 | 20 | if ri == gi == bi |
21 | | - @test ImageInTerminal._colorant2ansi(col, ImageInTerminal.TermColor256()) === _ref_col2ansi(r) |
| 21 | + @test _colorant2ansi(col, TermColor256()) === _ref_col2ansi(r) |
22 | 22 | else |
23 | | - @test ImageInTerminal._colorant2ansi(col, ImageInTerminal.TermColor256()) === _ref_col2ansi(r, g, b) |
| 23 | + @test _colorant2ansi(col, TermColor256()) === _ref_col2ansi(r, g, b) |
24 | 24 | end |
25 | 25 | end |
26 | 26 | end |
27 | 27 | @testset "Gray" begin |
28 | 28 | for col in rand(Gray, 10) |
29 | 29 | r = real(col) |
30 | | - @test ImageInTerminal._colorant2ansi(col, ImageInTerminal.TermColor256()) === _ref_col2ansi(r) |
| 30 | + @test _colorant2ansi(col, TermColor256()) === _ref_col2ansi(r) |
31 | 31 | end |
32 | 32 | end |
33 | 33 | end |
|
39 | 39 | for col in rand(RGB, 10) |
40 | 40 | r, g, b = red(col), green(col), blue(col) |
41 | 41 | ri, gi, bi = map(c->round(Int,255c), (r,g,b)) |
42 | | - @test ImageInTerminal._colorant2ansi(col, ImageInTerminal.TermColor24bit()) === (ri, gi, bi) |
| 42 | + @test _colorant2ansi(col, TermColor24bit()) === (ri, gi, bi) |
43 | 43 | end |
44 | 44 | end |
45 | 45 | @testset "Gray" begin |
46 | 46 | for col in rand(Gray, 10) |
47 | 47 | r = round(Int, 255*real(col)) |
48 | | - @test ImageInTerminal._colorant2ansi(col, ImageInTerminal.TermColor24bit()) === (r, r, r) |
| 48 | + @test _colorant2ansi(col, TermColor24bit()) === (r, r, r) |
49 | 49 | end |
50 | 50 | end |
51 | 51 | end |
|
55 | 55 | @testset "Non RGB" begin |
56 | 56 | for col_rgb in rand(RGB, 10) |
57 | 57 | col_other = convert(HSV, col_rgb) |
58 | | - @test ImageInTerminal._colorant2ansi(col_rgb, ImageInTerminal.TermColor24bit()) === ImageInTerminal._colorant2ansi(col_other, ImageInTerminal.TermColor24bit()) |
| 58 | + @test _colorant2ansi(col_rgb, TermColor24bit()) === _colorant2ansi(col_other, TermColor24bit()) |
59 | 59 | end |
60 | 60 | end |
61 | 61 |
|
|
64 | 64 | @testset "TransparentColor" begin |
65 | 65 | for col in (rand(RGB, 10)..., rand(HSV, 10)...) |
66 | 66 | acol = alphacolor(col, rand()) |
67 | | - @test ImageInTerminal._colorant2ansi(col, ImageInTerminal.TermColor24bit()) === ImageInTerminal._colorant2ansi(acol, ImageInTerminal.TermColor24bit()) |
| 67 | + @test _colorant2ansi(col, TermColor24bit()) === _colorant2ansi(acol, TermColor24bit()) |
68 | 68 | end |
69 | 69 | end |
70 | 70 | end |
|
74 | 74 | # Also compare functionality against the functions tested above |
75 | 75 | @testset "Exported Interface" begin |
76 | 76 | @testset "Validate exported interface boundaries" begin |
77 | | - @test_throws UndefVarError TermColor256() |
78 | | - @test_throws UndefVarError TermColor24bit() |
79 | | - @test_throws MethodError colorant2ansi(RGB(1.,1.,1.), ImageInTerminal.TermColor256()) |
80 | | - @test_throws MethodError colorant2ansi(RGB(1.,1.,1.), ImageInTerminal.TermColor24bit()) |
| 77 | + @test_throws MethodError colorant2ansi(RGB(1.,1.,1.), TermColor256()) |
| 78 | + @test_throws MethodError colorant2ansi(RGB(1.,1.,1.), TermColor24bit()) |
81 | 79 | end |
82 | 80 |
|
83 | 81 | @testset "256 colors" begin |
84 | 82 | for col in (rand(RGB, 10)..., rand(Gray, 10)...) |
85 | 83 | # compare against non-exported interface, |
86 | 84 | # which we already tested above |
87 | | - @test colorant2ansi(col) === ImageInTerminal._colorant2ansi(col, ImageInTerminal.TermColor256()) |
| 85 | + @test colorant2ansi(col) === _colorant2ansi(col, TermColor256()) |
88 | 86 | end |
89 | 87 | end |
90 | 88 |
|
|
104 | 102 | end |
105 | 103 | end |
106 | 104 | end |
107 | | - |
0 commit comments