forked from marcusolsson/tui-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtext_edit_test.go
52 lines (47 loc) · 909 Bytes
/
text_edit_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
package tui
import (
"image"
"testing"
)
var drawTextEditTests = []struct {
test string
size image.Point
setup func() *TextEdit
want string
}{
{
test: "Simple",
size: image.Point{15, 5},
setup: func() *TextEdit {
e := NewTextEdit()
e.SetText("Lorem ipsum dolor sit amet")
e.SetWordWrap(true)
return e
},
want: `
Lorem ipsum
dolor sit amet
...............
...............
...............
`,
},
}
func TestTextEdit_Draw(t *testing.T) {
for _, tt := range drawTextEditTests {
tt := tt
t.Run(tt.test, func(t *testing.T) {
var surface *TestSurface
if tt.size.X == 0 && tt.size.Y == 0 {
surface = NewTestSurface(10, 5)
} else {
surface = NewTestSurface(tt.size.X, tt.size.Y)
}
painter := NewPainter(surface, NewTheme())
painter.Repaint(tt.setup())
if diff := surfaceEquals(surface, tt.want); diff != "" {
t.Error(diff)
}
})
}
}