-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsheet_test.go
76 lines (66 loc) · 1.7 KB
/
sheet_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
package excelizex
import (
"fmt"
"strconv"
"testing"
)
type TestNoStyle struct {
Notice string `excel:"notice"`
Name string `excel:"header|学生姓名"`
Phone int `excel:"header|学生号码"`
}
type TestHasStyle struct {
Notice string `excel:"notice" style:"default-notice"`
Name string `excel:"header|学生姓名" style:"default-header"`
Phone int `excel:"header|学生号码" style:"default-header-red"`
Id int `excel:"header|学生编号" style:"default-header-red"`
p []*TestNoStyle
}
func TestGenerateSheet(t *testing.T) {
t.Run("no_data_no_style", func(t *testing.T) {
newSheet := NewSheet("helloWorld", new(TestNoStyle))
fmt.Println(newSheet)
})
t.Run("no_data_no_style_has_notice", func(t *testing.T) {
ttt := new(TestNoStyle)
ttt.Notice = "new(TestNoStyle)new(TestNoStyle)new(TestNoStyle)"
newSheet := NewSheet("helloWorld", ttt)
fmt.Println(newSheet)
})
t.Run("has_data_no_style", func(t *testing.T) {
var hasdata []*TestHasStyle
for i := 0; i < 100; i++ {
hasdata = append(
hasdata,
&TestHasStyle{
Notice: "你好世界",
Name: "hello" + strconv.FormatInt(int64(i), 10),
Phone: i,
Id: i,
},
)
}
newSheet := NewSheet("helloWorld", hasdata)
fmt.Println(newSheet)
})
t.Run("has_data_has_style", func(t *testing.T) {
var hasdata []*TestHasStyle
for i := 0; i < 100; i++ {
hasdata = append(
hasdata,
&TestHasStyle{
Notice: "你好世界",
Name: "hello" + strconv.FormatInt(int64(i), 10),
Phone: i,
Id: i,
},
)
}
m := newMetas(hasdata)
for _, rr := range m.data {
t.Log(rr)
}
newSheet := NewSheet("helloWorld", hasdata)
fmt.Println(newSheet)
})
}