forked from tealeg/xlsx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFileToSlice_test.go
35 lines (29 loc) · 905 Bytes
/
FileToSlice_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
package xlsx
import (
. "gopkg.in/check.v1"
)
type SliceReaderSuite struct{}
var _ = Suite(&SliceReaderSuite{})
func (s *SliceReaderSuite) TestFileToSlice(c *C) {
output, err := FileToSlice("testfile.xlsx")
c.Assert(err, IsNil)
fileToSliceCheckOutput(c, output)
}
func (s *SliceReaderSuite) TestFileObjToSlice(c *C) {
f, err := OpenFile("testfile.xlsx")
output, err := f.ToSlice()
c.Assert(err, IsNil)
fileToSliceCheckOutput(c, output)
}
func fileToSliceCheckOutput(c *C, output [][][]string) {
c.Assert(len(output), Equals, 3)
c.Assert(len(output[0]), Equals, 2)
c.Assert(len(output[0][0]), Equals, 2)
c.Assert(output[0][0][0], Equals, "Foo")
c.Assert(output[0][0][1], Equals, "Bar")
c.Assert(len(output[0][1]), Equals, 2)
c.Assert(output[0][1][0], Equals, "Baz")
c.Assert(output[0][1][1], Equals, "Quuk")
c.Assert(len(output[1]), Equals, 0)
c.Assert(len(output[2]), Equals, 0)
}