forked from asciimoo/drawille
-
Notifications
You must be signed in to change notification settings - Fork 9
/
drawille_test.go
109 lines (91 loc) · 2.01 KB
/
drawille_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package drawille
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestSet(t *testing.T) {
c := NewCanvas()
c.Set(0, 0)
assert.True(t, c.Get(0, 0))
}
func TestUnsetEmpty(t *testing.T) {
c := NewCanvas()
c.Set(1, 1)
c.UnSet(1, 1)
assert.False(t, c.Get(0, 0))
assert.False(t, c.Get(0, 1))
assert.False(t, c.Get(1, 0))
assert.False(t, c.Get(1, 1))
}
func TestUnsetNonempty(t *testing.T) {
c := NewCanvas()
c.Set(0, 0)
c.Set(0, 1)
c.UnSet(0, 1)
assert.True(t, c.Get(0, 0))
}
func TestClear(t *testing.T) {
c := NewCanvas()
c.Set(1, 1)
c.Clear()
assert.False(t, c.Get(1, 1))
}
func TestToggle(t *testing.T) {
c := NewCanvas()
c.Toggle(0, 0)
assert.True(t, c.Get(0, 0))
c.Toggle(0, 0)
assert.False(t, c.Get(0, 0))
}
func TestSetText(t *testing.T) {
c := NewCanvas()
c.SetText(0, 0, "asdf")
assert.Equal(t, "asdf\n", c.Frame(0, 0, 7, 3))
}
func TestFrame(t *testing.T) {
c := NewCanvas()
assert.Equal(t, "\u2800\n", c.Frame(0, 0, 1, 3))
c.Set(0, 0)
assert.Equal(t, "⠁\n", c.Frame(0, 0, 1, 3))
}
// test_max_min_limits could not be ported
func TestGet(t *testing.T) {
c := NewCanvas()
assert.False(t, c.Get(0, 0))
c.Set(0, 0)
assert.True(t, c.Get(0, 0))
assert.False(t, c.Get(0, 1))
assert.False(t, c.Get(1, 0))
assert.False(t, c.Get(1, 1))
}
func TestDrawLineSinglePixel(t *testing.T) {
c := NewCanvas()
c.DrawLine(0, 0, 0, 0)
assert.True(t, c.Get(0, 0))
}
func TestDrawLineRow(t *testing.T) {
c := NewCanvas()
c.DrawLine(0, 0, 1, 0)
assert.True(t, c.Get(0, 0))
assert.True(t, c.Get(1, 0))
}
func TestDrawLineColumn(t *testing.T) {
c := NewCanvas()
c.DrawLine(0, 0, 0, 1)
assert.True(t, c.Get(0, 0))
assert.True(t, c.Get(0, 1))
}
func TestDrawLineDiagonal(t *testing.T) {
c := NewCanvas()
c.DrawLine(0, 0, 1, 1)
assert.True(t, c.Get(0, 0))
assert.True(t, c.Get(1, 1))
}
func TestDrawLineDiagonalNonSquare(t *testing.T) {
c := NewCanvas()
c.DrawLine(0, 0, 2, 3)
assert.True(t, c.Get(0, 0))
assert.True(t, c.Get(1, 1))
assert.True(t, c.Get(1, 2))
assert.True(t, c.Get(2, 3))
}