-
Notifications
You must be signed in to change notification settings - Fork 0
/
log_test.go
80 lines (73 loc) · 1.27 KB
/
log_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
package honlog
import (
"fmt"
"testing"
)
func TestLog(t *testing.T) {
tSize := 20
logger := NewLoggerWithSize(tSize)
t.Log("Write 10000 logs")
for i:=0; i<10000; i++{
logger.Add(fmt.Sprintf("Log: %d", i))
}
outChan := make(chan string)
go func(){
for {
s, ok:= <- outChan
if ok {
fmt.Printf("Get: %s\n", s)
} else {
//fmt.Printf("Get: %s\n", s)
t.Log("Channel close")
return
}
}
}()
logger.OutputChan(outChan)
testcb := func(s string) {
fmt.Printf("Func Get: %s\n", s)
}
testdone := func() {
fmt.Println("Func End")
}
logger.OutputFunc(testcb, testdone)
}
func TestTree(t *testing.T) {
tree := NewTree("A", nil)
err := tree.Append("B", nil, "C")
if err != nil {
t.Error(err)
}
err = tree.Append("E", nil, "D")
if err != nil {
t.Error(err)
}
err = tree.Append("C", nil, "A")
if err != nil {
t.Error(err)
}
err = tree.Append("F", nil, "D")
if err != nil {
t.Error(err)
}
err = tree.Append("D", nil, "A")
if err != nil {
t.Error(err)
}
err = tree.Append("G", nil, "D")
if err != nil {
t.Error(err)
}
err = tree.Append("H", nil, "A")
if err != nil {
t.Error(err)
}
err = tree.Append("I", nil, "H")
if err != nil {
t.Error(err)
}
err = tree.WriteCSV("test.csv")
if err != nil {
t.Error(err)
}
}