This repository has been archived by the owner on Mar 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
report_test.go
135 lines (127 loc) · 3.01 KB
/
report_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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package report
import "testing"
func TestNewdoc(t *testing.T) {
doc := NewDoc()
err := doc.InitDoc("demo.doc")
if err != nil {
doc.CloseReport()
t.Errorf("init doc failed")
} else {
doc.CloseReport()
t.Log("init doc OK")
}
}
func TestWriteHead(t *testing.T) {
doc := NewDoc()
doc.InitDoc("demo.doc")
err := doc.WriteHead()
if err != nil {
t.Errorf(err.Error())
} else {
t.Log("WriteHead Succeed")
}
doc.Doc.Close()
}
func TestWriteTitle1(t *testing.T) {
doc := NewDoc()
doc.InitDoc("demo.doc")
err := doc.WriteTitle1(NewText("Hello World"))
if err != nil {
t.Errorf(err.Error())
} else {
t.Log("TestWriteTitle1 Succeed")
}
doc.Doc.Close()
}
func TestWriteTitle2(t *testing.T) {
doc := NewDoc()
doc.InitDoc("demo.doc")
err := doc.WriteTitle2(NewText("Hello World"))
if err != nil {
t.Errorf(err.Error())
} else {
t.Log("TestWriteTitle2 Succeed")
}
doc.Doc.Close()
}
func TestWriteTitle3(t *testing.T) {
doc := NewDoc()
doc.InitDoc("demo.doc")
err := doc.WriteTitle3(NewText("Hello World"))
if err != nil {
t.Errorf(err.Error())
} else {
t.Log("TestWriteTitle3 Succeed")
}
doc.Doc.Close()
}
func TestWriteBr(t *testing.T) {
doc := NewDoc()
doc.InitDoc("demo.doc")
err := doc.WriteBR()
if err != nil {
t.Errorf(err.Error())
} else {
t.Log("TestWriteBr Succeed")
}
doc.Doc.Close()
}
func TestWriteText(t *testing.T) {
doc := NewDoc()
doc.InitDoc("demo.doc")
err := doc.WriteText(NewText("Hello World"))
if err != nil {
t.Errorf(err.Error())
} else {
t.Log("TestWriteText succeed")
}
doc.Doc.Close()
}
func TestWriteTable(t *testing.T) {
doc := NewDoc()
doc.InitDoc("demo.doc")
// tabletd := NewTableTD([]interface{}{{, }, {{"a"}, {"b"}}, {{"xxx"}, {"yyyy"}}})
td0 := NewTableTD([]interface{}{"aaa"})
td1 := NewTableTD([]interface{}{"bbb"})
td2 := NewTableTD([]interface{}{"a"})
td3 := NewTableTD([]interface{}{"b"})
td4 := NewTableTD([]interface{}{"xxx"})
td5 := NewTableTD([]interface{}{"yyyyy"})
table := [][]*TableTD{{td0, td1}, {td2, td3}, {td4, td5}}
head := [][]interface{}{{"Hello"}, {"World"}}
trSpan := []int{0, 0, 0}
tdw := []int{4190, 4190, 4190, 4190, 4190, 4190}
thw := []int{4190, 4190}
tableObj := NewTable("test", false, table, head, thw, trSpan, tdw)
err := doc.WriteTable(tableObj)
if err != nil {
t.Errorf(err.Error())
} else {
t.Log("TestWriteTable Succeed")
}
doc.Doc.Close()
}
func TestWriteImage(t *testing.T) {
doc := NewDoc()
doc.InitDoc("demo.doc")
image1 := NewImage("1.png", "./images/offlineWS-102-risk.png", 140.00, 160.00, "")
image2 := NewImage("2.png", "./images/offlineWS-102-url.png", 140.00, 160.00, "")
images := []*Image{image1, image2}
if err := doc.WriteImage(false, "", images...); err != nil {
t.Errorf(err.Error())
} else {
t.Log("TestWriteImage Succeed")
}
doc.Doc.Close()
}
func TestWriteEndHead(t *testing.T) {
doc := NewDoc()
doc.InitDoc("demo.doc")
err := doc.WriteEndHead(true, "pages", "Hello World", "")
if err != nil {
t.Errorf(err.Error())
} else {
t.Log("TestWriteEndHead Succeed")
}
doc.Doc.Close()
}