-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
spreadsheet_test.go
53 lines (39 loc) · 1.59 KB
/
spreadsheet_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
// Copyright (c) 2017 Andrey Gayvoronsky <[email protected]>
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package xlsx
import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
)
func TestSpreadsheet_Sheet(t *testing.T) {
xl, err := Open("./test_files/example_simple.xlsx")
assert.NotNil(t, xl)
assert.Nil(t, err)
assert.IsType(t, &Spreadsheet{}, xl)
defer xl.Close()
//stream mode should be new each time
sheet := xl.Sheet(0, SheetModeStream|SheetModeMultiPhase)
assert.Equal(t, sheetModeRead|SheetModeStream|SheetModeMultiPhase, sheet.mode())
require.Panics(t, func() {
xl.Sheet(0, SheetModeStream|SheetModeIgnoreDimension)
})
sheet = xl.Sheet(0, SheetModeStream|SheetModeMultiPhase|SheetModeIgnoreDimension)
assert.Equal(t, sheetModeRead|SheetModeStream|SheetModeMultiPhase|SheetModeIgnoreDimension, sheet.mode())
//normal mode should not be changed
sheet = xl.Sheet(0, SheetModeIgnoreDimension)
assert.Equal(t, sheetModeRead|sheetModeWrite|SheetModeIgnoreDimension, sheet.mode())
sheet = xl.Sheet(0)
assert.Equal(t, sheetModeRead|sheetModeWrite|SheetModeIgnoreDimension, sheet.mode())
//stream mode should not work after normal mode
assert.Panics(t, func() {
sheet = xl.Sheet(0, SheetModeStream)
})
sheet = xl.AddSheet("a new sheet")
assert.Equal(t, sheetModeRead|sheetModeWrite, sheet.mode())
sheet = xl.Sheet(1)
assert.Equal(t, sheetModeRead|sheetModeWrite, sheet.mode())
sheet = xl.Sheet(1, SheetModeIgnoreDimension)
assert.Equal(t, sheetModeRead|sheetModeWrite, sheet.mode())
}