-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsheet_test.go
63 lines (48 loc) · 1.32 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
package excelsior_test
import (
"testing"
"github.com/kakilangit/excelsior"
)
type nopSheetData struct {
row excelsior.Row
}
func (nopSheetData) Total() int {
return 1
}
func (d nopSheetData) Row(int) excelsior.Row {
return d.row
}
func TestSheet(t *testing.T) {
header := excelsior.Row{"Name", "Age"}
getRowStyle := func(int) int { return 0 }
headStyleID := 1
data := nopSheetData{row: excelsior.Row{"John Doe", 30}}
s := excelsior.NewSheet(header, getRowStyle, headStyleID, data)
if s.TotalColumn() != 2 {
t.Errorf("TotalColumn() = %d; want 2", s.TotalColumn())
}
if s.HeaderRow()[0] != "Name" {
t.Errorf("HeaderRow()[0] = %s; want Name", s.HeaderRow()[0])
}
if s.HeaderRow()[1] != "Age" {
t.Errorf("HeaderRow()[1] = %s; want Age", s.HeaderRow()[1])
}
if s.HeaderRowStyle()(0) != 1 {
t.Errorf("HeaderRowStyle()(0) = %d; want 1", s.HeaderRowStyle()(0))
}
if s.HeaderRowStyle()(1) != 1 {
t.Errorf("HeaderRowStyle()(1) = %d; want 1", s.HeaderRowStyle()(1))
}
if s.RowStyle()(0) != 0 {
t.Errorf("RowStyle()(0) = %d; want 0", s.RowStyle()(0))
}
if s.RowStyle()(1) != 0 {
t.Errorf("RowStyle()(1) = %d; want 0", s.RowStyle()(1))
}
if s.Row(0)[0] != "John Doe" {
t.Errorf("Row(0)[0] = %s; want John Doe", s.Row(0)[0])
}
if s.Row(0)[1] != 30 {
t.Errorf("Row(0)[1] = %d; want 30", s.Row(0)[1])
}
}