-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontainer_test.go
96 lines (79 loc) · 2.07 KB
/
container_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
package tooey
import (
"testing"
)
func TestContainers(t *testing.T) {
/*
Test that containers render and that a general container in
flex row with two children will fill the screen
half and half
*/
err := InitSim()
if err != nil {
t.Fatal("Failed to initialize simulation screen")
}
defer Close()
w, h := DrawableDimensions()
s := GetRootScreen()
e := NewContainer(DefaultTheme)
e.Direction = FlexRow
e.SetRect(0, 0, w-1, h)
e1 := NewElement(DefaultTheme)
e2 := NewElement(DefaultTheme)
e.Wrap(
NewFlexChild(1, e1),
NewFlexChild(1, e2),
)
Render(e)
// runeE1TopLeft, _, _, _ := s.GetContent(1, 0)
// if runeE1TopLeft != DefaultULCorner {
// t.Fatalf("Expected 1,0 to be [%s][%v] but got [%s][%v]\n", string(DefaultULCorner), DefaultULCorner, string(runeE1TopLeft), runeE1TopLeft)
// }
topRow := make([]rune, w)
for rowX := 0; rowX < w; rowX++ {
if rowX == 0 {
topRow[rowX] = DefaultULCorner
} else if rowX == 78 {
topRow[rowX] = DefaultURCorner
} else {
topRow[rowX] = DefaultHLine
}
}
for x := 0; x < w; x++ {
r, _, _, _ := s.GetContent(x, 0)
if r != topRow[x] {
t.Fatalf("Expected (%d, %d) rune to equal [%s][%v] but got [%s][%v]\n", x, 0, string(topRow[x]), topRow[x], string(r), r)
}
}
secondRow := make([]rune, w)
for rowX := 0; rowX < w; rowX++ {
if rowX == 0 {
secondRow[rowX] = DefaultVLine
} else if rowX == 1 {
secondRow[rowX] = DefaultULCorner
} else if rowX == 39 {
secondRow[rowX] = DefaultURCorner
} else if rowX == 40 {
secondRow[rowX] = DefaultULCorner
} else if rowX == 77 {
secondRow[rowX] = DefaultURCorner
} else if rowX == 78 {
secondRow[rowX] = DefaultVLine
} else {
secondRow[rowX] = DefaultHLine
}
}
for x := 0; x < w; x++ {
r, _, _, _ := s.GetContent(x, 1)
if r != secondRow[x] {
t.Fatalf("Expected (%d, %d) rune to equal [%s][%v] but got [%s][%v]\n", x, 1, string(secondRow[x]), secondRow[x], string(r), r)
}
}
/*
Used to discover chars
*/
// for x := 0; x < w; x++ {
// r, _, _, _ := s.GetContent(x, 1)
// t.Logf("X: %d | [%s]\n", x, string(r))
// }
}