-
Notifications
You must be signed in to change notification settings - Fork 7
/
textblock_test.go
67 lines (57 loc) · 1.36 KB
/
textblock_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
package boilerpipe
import (
"testing"
)
func TestLabelStack(t *testing.T) {
labelStack := NewLabelStack()
labelStack.Push(LabelHeading, LabelHeading1, LabelHeading2)
if l := labelStack.Len(); l != 3 {
t.Fatalf("expected length of 3 but got %d", l)
}
label, ok := labelStack.Pop()
if !ok {
t.Fatal("expected ok")
}
if label != LabelHeading2 {
t.Fatalf("expected LabelHeading2 but got %s", label)
}
labels := labelStack.PopAll()
if l := len(labels); l != 2 {
t.Fatalf("expected 2 labels but got %d", l)
}
if labels[0] != LabelHeading1 {
t.Fatalf("expected LabelHeading1 but got %s", label)
}
if labels[1] != LabelHeading {
t.Fatalf("expected LabelHeading but got %s", label)
}
if l := labelStack.Len(); l != 0 {
t.Fatalf("expected 0 labels but got %d", l)
}
}
//func NewLabelStack() *LabelStack {
// return &LabelStack{
// labels: make([]Label, 0),
// }
//}
//
//func (x *LabelStack) Pop() (label Label, ok bool) {
// if len(x.labels) == 0 {
// return
// }
// label = x.labels[len(x.labels)-1]
// ok = true
// x.labels = x.labels[:len(x.labels)-1]
// return
//}
//
//func (x *LabelStack) PopAll() (labels []Label) {
// labels = x.labels
// x.labels = nil
// x.labels = make([]Label, 0)
// return
//}
//
//func (x *LabelStack) Push(labels ...Label) {
// x.labels = append(x.labels, labels...)
//}