Tests refactoring

Primary motivation: Avoid statefull tests with not ignorable git file tree changes.
Multiple tests reads and overwrites signle file for won needs.
Multiple tests reads and overwrites file under version control.

Secondary motivation: Minimal tests logic aligment, separate error expectation
and not error expectation tests. Introduce sub-test over test data sets and so far.

This commit is not ideal but necessary (IMHO)
formula
Veniamin Albaev 6 years ago
parent 9a6f66a996
commit 35426ed5dc

1
.gitignore vendored

@ -0,0 +1 @@
test/Test*.xlsx

@ -1,6 +1,10 @@
package excelize package excelize
import "testing" import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestCheckCellInArea(t *testing.T) { func TestCheckCellInArea(t *testing.T) {
expectedTrueCellInAreaList := [][2]string{ expectedTrueCellInAreaList := [][2]string{
@ -14,11 +18,8 @@ func TestCheckCellInArea(t *testing.T) {
cell := expectedTrueCellInArea[0] cell := expectedTrueCellInArea[0]
area := expectedTrueCellInArea[1] area := expectedTrueCellInArea[1]
cellInArea := checkCellInArea(cell, area) assert.True(t, checkCellInArea(cell, area),
"Expected cell %v to be in area %v, got false\n", cell, area)
if !cellInArea {
t.Fatalf("Expected cell %v to be in area %v, got false\n", cell, area)
}
} }
expectedFalseCellInAreaList := [][2]string{ expectedFalseCellInAreaList := [][2]string{
@ -31,10 +32,7 @@ func TestCheckCellInArea(t *testing.T) {
cell := expectedFalseCellInArea[0] cell := expectedFalseCellInArea[0]
area := expectedFalseCellInArea[1] area := expectedFalseCellInArea[1]
cellInArea := checkCellInArea(cell, area) assert.False(t, checkCellInArea(cell, area),
"Expected cell %v not to be inside of area %v, but got true\n", cell, area)
if cellInArea {
t.Fatalf("Expected cell %v not to be inside of area %v, but got true\n", cell, area)
}
} }
} }

@ -4,6 +4,8 @@ import (
"bytes" "bytes"
"encoding/xml" "encoding/xml"
"testing" "testing"
"github.com/stretchr/testify/assert"
) )
func TestChartSize(t *testing.T) { func TestChartSize(t *testing.T) {
@ -22,18 +24,18 @@ func TestChartSize(t *testing.T) {
xlsx.AddChart("Sheet1", "E4", `{"type":"col3DClustered","dimension":{"width":640, "height":480},"series":[{"name":"Sheet1!$A$2","categories":"Sheet1!$B$1:$D$1","values":"Sheet1!$B$2:$D$2"},{"name":"Sheet1!$A$3","categories":"Sheet1!$B$1:$D$1","values":"Sheet1!$B$3:$D$3"},{"name":"Sheet1!$A$4","categories":"Sheet1!$B$1:$D$1","values":"Sheet1!$B$4:$D$4"}],"title":{"name":"Fruit 3D Clustered Column Chart"}}`) xlsx.AddChart("Sheet1", "E4", `{"type":"col3DClustered","dimension":{"width":640, "height":480},"series":[{"name":"Sheet1!$A$2","categories":"Sheet1!$B$1:$D$1","values":"Sheet1!$B$2:$D$2"},{"name":"Sheet1!$A$3","categories":"Sheet1!$B$1:$D$1","values":"Sheet1!$B$3:$D$3"},{"name":"Sheet1!$A$4","categories":"Sheet1!$B$1:$D$1","values":"Sheet1!$B$4:$D$4"}],"title":{"name":"Fruit 3D Clustered Column Chart"}}`)
// Save xlsx file by the given path. // Save xlsx file by the given path.
err := xlsx.Write(&buffer) err := xlsx.Write(&buffer)
if err != nil { if !assert.NoError(t, err) {
t.Fatal(err) t.FailNow()
} }
newFile, err := OpenReader(&buffer) newFile, err := OpenReader(&buffer)
if err != nil { if !assert.NoError(t, err) {
t.Fatal(err) t.FailNow()
} }
chartsNum := newFile.countCharts() chartsNum := newFile.countCharts()
if chartsNum != 1 { if !assert.Equal(t, 1, chartsNum, "Expected 1 chart, actual %d", chartsNum) {
t.Fatalf("Expected 1 chart, actual %d", chartsNum) t.FailNow()
} }
var ( var (
@ -42,25 +44,27 @@ func TestChartSize(t *testing.T) {
) )
content, ok := newFile.XLSX["xl/drawings/drawing1.xml"] content, ok := newFile.XLSX["xl/drawings/drawing1.xml"]
if !ok { assert.True(t, ok, "Can't open the chart")
t.Fatal("Can't open the chart")
}
err = xml.Unmarshal([]byte(content), &workdir) err = xml.Unmarshal([]byte(content), &workdir)
if err != nil { if !assert.NoError(t, err) {
t.Fatal(err) t.FailNow()
} }
err = xml.Unmarshal([]byte("<decodeTwoCellAnchor>"+workdir.TwoCellAnchor[0].Content+"</decodeTwoCellAnchor>"), &anchor) err = xml.Unmarshal([]byte("<decodeTwoCellAnchor>"+workdir.TwoCellAnchor[0].Content+"</decodeTwoCellAnchor>"), &anchor)
if err != nil { if !assert.NoError(t, err) {
t.Fatal(err) t.FailNow()
} }
if anchor.From.Col != 4 || anchor.From.Row != 3 { if !assert.Equal(t, 4, anchor.From.Col, "Expected 'from' column 4") ||
t.Fatalf("From: Expected column 4, row 3, actual column %d, row %d", anchor.From.Col, anchor.From.Row) !assert.Equal(t, 3, anchor.From.Row, "Expected 'from' row 3") {
}
if anchor.To.Col != 14 || anchor.To.Row != 27 { t.FailNow()
t.Fatalf("To: Expected column 14, row 27, actual column %d, row %d", anchor.To.Col, anchor.To.Row)
} }
if !assert.Equal(t, 14, anchor.To.Col, "Expected 'to' column 14") ||
!assert.Equal(t, 27, anchor.To.Row, "Expected 'to' row 27") {
t.FailNow()
}
} }

@ -9,9 +9,15 @@
package excelize package excelize
import "testing" import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestDataValidation(t *testing.T) { func TestDataValidation(t *testing.T) {
const resultFile = "./test/TestDataValidation.xlsx"
xlsx := NewFile() xlsx := NewFile()
dvRange := NewDataValidation(true) dvRange := NewDataValidation(true)
@ -21,37 +27,57 @@ func TestDataValidation(t *testing.T) {
dvRange.SetError(DataValidationErrorStyleWarning, "error title", "error body") dvRange.SetError(DataValidationErrorStyleWarning, "error title", "error body")
dvRange.SetError(DataValidationErrorStyleInformation, "error title", "error body") dvRange.SetError(DataValidationErrorStyleInformation, "error title", "error body")
xlsx.AddDataValidation("Sheet1", dvRange) xlsx.AddDataValidation("Sheet1", dvRange)
if !assert.NoError(t, xlsx.SaveAs(resultFile)) {
t.FailNow()
}
dvRange = NewDataValidation(true) dvRange = NewDataValidation(true)
dvRange.Sqref = "A3:B4" dvRange.Sqref = "A3:B4"
dvRange.SetRange(10, 20, DataValidationTypeWhole, DataValidationOperatorGreaterThan) dvRange.SetRange(10, 20, DataValidationTypeWhole, DataValidationOperatorGreaterThan)
dvRange.SetInput("input title", "input body") dvRange.SetInput("input title", "input body")
xlsx.AddDataValidation("Sheet1", dvRange) xlsx.AddDataValidation("Sheet1", dvRange)
if !assert.NoError(t, xlsx.SaveAs(resultFile)) {
t.FailNow()
}
dvRange = NewDataValidation(true) dvRange = NewDataValidation(true)
dvRange.Sqref = "A5:B6" dvRange.Sqref = "A5:B6"
dvRange.SetDropList([]string{"1", "2", "3"}) dvRange.SetDropList([]string{"1", "2", "3"})
xlsx.AddDataValidation("Sheet1", dvRange) xlsx.AddDataValidation("Sheet1", dvRange)
if !assert.NoError(t, xlsx.SaveAs(resultFile)) {
t.FailNow()
}
}
func TestDataValidationError(t *testing.T) {
const resultFile = "./test/TestDataValidationError.xlsx"
xlsx := NewFile()
xlsx.SetCellStr("Sheet1", "E1", "E1") xlsx.SetCellStr("Sheet1", "E1", "E1")
xlsx.SetCellStr("Sheet1", "E2", "E2") xlsx.SetCellStr("Sheet1", "E2", "E2")
xlsx.SetCellStr("Sheet1", "E3", "E3") xlsx.SetCellStr("Sheet1", "E3", "E3")
dvRange = NewDataValidation(true)
dvRange := NewDataValidation(true)
dvRange.SetSqref("A7:B8") dvRange.SetSqref("A7:B8")
dvRange.SetSqref("A7:B8") dvRange.SetSqref("A7:B8")
dvRange.SetSqrefDropList("$E$1:$E$3", true) dvRange.SetSqrefDropList("$E$1:$E$3", true)
err := dvRange.SetSqrefDropList("$E$1:$E$3", false) err := dvRange.SetSqrefDropList("$E$1:$E$3", false)
t.Log(err) assert.EqualError(t, err, "cross-sheet sqref cell are not supported")
xlsx.AddDataValidation("Sheet1", dvRange) xlsx.AddDataValidation("Sheet1", dvRange)
if !assert.NoError(t, xlsx.SaveAs(resultFile)) {
t.FailNow()
}
dvRange = NewDataValidation(true) dvRange = NewDataValidation(true)
dvRange.SetDropList(make([]string, 258)) dvRange.SetDropList(make([]string, 258))
err = dvRange.SetRange(10, 20, DataValidationTypeWhole, DataValidationOperatorGreaterThan) err = dvRange.SetRange(10, 20, DataValidationTypeWhole, DataValidationOperatorGreaterThan)
t.Log(err) assert.EqualError(t, err, "data validation must be 0-255 characters")
// Test write file to given path. xlsx.AddDataValidation("Sheet1", dvRange)
err = xlsx.SaveAs("./test/Book_data_validation.xlsx") if !assert.NoError(t, xlsx.SaveAs(resultFile)) {
if err != nil { t.FailNow()
t.Error(err)
} }
} }

@ -1,8 +1,11 @@
package excelize package excelize
import ( import (
"fmt"
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/assert"
) )
type dateTest struct { type dateTest struct {
@ -18,10 +21,10 @@ func TestTimeToExcelTime(t *testing.T) {
{401769.0, time.Date(3000, 1, 1, 0, 0, 0, 0, time.UTC)}, {401769.0, time.Date(3000, 1, 1, 0, 0, 0, 0, time.UTC)},
} }
for _, test := range trueExpectedInputList { for i, test := range trueExpectedInputList {
if test.ExcelValue != timeToExcelTime(test.GoValue) { t.Run(fmt.Sprintf("TestData%d", i+1), func(t *testing.T) {
t.Fatalf("Expected %v from %v = true, got %v\n", test.ExcelValue, test.GoValue, timeToExcelTime(test.GoValue)) assert.Equal(t, test.ExcelValue, timeToExcelTime(test.GoValue))
} })
} }
} }
@ -34,9 +37,9 @@ func TestTimeFromExcelTime(t *testing.T) {
{401769.0, time.Date(3000, 1, 1, 0, 0, 0, 0, time.UTC)}, {401769.0, time.Date(3000, 1, 1, 0, 0, 0, 0, time.UTC)},
} }
for _, test := range trueExpectedInputList { for i, test := range trueExpectedInputList {
if test.GoValue != timeFromExcelTime(test.ExcelValue, false) { t.Run(fmt.Sprintf("TestData%d", i+1), func(t *testing.T) {
t.Fatalf("Expected %v from %v = true, got %v\n", test.GoValue, test.ExcelValue, timeFromExcelTime(test.ExcelValue, false)) assert.Equal(t, test.GoValue, timeFromExcelTime(test.ExcelValue, false))
} })
} }
} }

File diff suppressed because it is too large Load Diff

@ -4,5 +4,5 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
github.com/pmezard/go-difflib v1.0.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/testify v1.2.2 github.com/stretchr/testify v1.2.3-0.20181224173747-660f15d67dbb
) )

@ -4,5 +4,5 @@ github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.3-0.20181224173747-660f15d67dbb h1:cRItZejS4Ok67vfCdrbGIaqk86wmtQNOjVD7jSyS2aw=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.3-0.20181224173747-660f15d67dbb/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=

@ -1,8 +1,13 @@
package excelize package excelize
import "testing" import (
"fmt"
"testing"
func TestAxisLowerOrEqualThan(t *testing.T) { "github.com/stretchr/testify/assert"
)
func TestAxisLowerOrEqualThanIsTrue(t *testing.T) {
trueExpectedInputList := [][2]string{ trueExpectedInputList := [][2]string{
{"A", "B"}, {"A", "B"},
{"A", "AA"}, {"A", "AA"},
@ -12,13 +17,14 @@ func TestAxisLowerOrEqualThan(t *testing.T) {
{"2", "11"}, {"2", "11"},
} }
for _, trueExpectedInput := range trueExpectedInputList { for i, trueExpectedInput := range trueExpectedInputList {
isLowerOrEqual := axisLowerOrEqualThan(trueExpectedInput[0], trueExpectedInput[1]) t.Run(fmt.Sprintf("TestData%d", i), func(t *testing.T) {
if !isLowerOrEqual { assert.True(t, axisLowerOrEqualThan(trueExpectedInput[0], trueExpectedInput[1]))
t.Fatalf("Expected %v <= %v = true, got false\n", trueExpectedInput[0], trueExpectedInput[1]) })
}
} }
}
func TestAxisLowerOrEqualThanIsFalse(t *testing.T) {
falseExpectedInputList := [][2]string{ falseExpectedInputList := [][2]string{
{"B", "A"}, {"B", "A"},
{"AA", "A"}, {"AA", "A"},
@ -28,32 +34,27 @@ func TestAxisLowerOrEqualThan(t *testing.T) {
{"11", "2"}, {"11", "2"},
} }
for _, falseExpectedInput := range falseExpectedInputList { for i, falseExpectedInput := range falseExpectedInputList {
isLowerOrEqual := axisLowerOrEqualThan(falseExpectedInput[0], falseExpectedInput[1]) t.Run(fmt.Sprintf("TestData%d", i), func(t *testing.T) {
if isLowerOrEqual { assert.False(t, axisLowerOrEqualThan(falseExpectedInput[0], falseExpectedInput[1]))
t.Fatalf("Expected %v <= %v = false, got true\n", falseExpectedInput[0], falseExpectedInput[1]) })
}
} }
} }
func TestGetCellColRow(t *testing.T) { func TestGetCellColRow(t *testing.T) {
cellExpectedColRowList := map[string][2]string{ cellExpectedColRowList := [][3]string{
"C220": {"C", "220"}, {"C220", "C", "220"},
"aaef42": {"aaef", "42"}, {"aaef42", "aaef", "42"},
"bonjour": {"bonjour", ""}, {"bonjour", "bonjour", ""},
"59": {"", "59"}, {"59", "", "59"},
"": {"", ""}, {"", "", ""},
} }
for cell, expectedColRow := range cellExpectedColRowList { for i, test := range cellExpectedColRowList {
col, row := getCellColRow(cell) t.Run(fmt.Sprintf("TestData%d", i), func(t *testing.T) {
col, row := getCellColRow(test[0])
if col != expectedColRow[0] { assert.Equal(t, test[1], col, "Unexpected col")
t.Fatalf("Expected cell %v to return col %v, got col %v\n", cell, expectedColRow[0], col) assert.Equal(t, test[2], row, "Unexpected row")
} })
if row != expectedColRow[1] {
t.Fatalf("Expected cell %v to return row %v, got row %v\n", cell, expectedColRow[1], row)
}
} }
} }

@ -2,11 +2,12 @@ package excelize_test
import ( import (
"fmt" "fmt"
"reflect"
"testing" "testing"
"github.com/360EntSecGroup-Skylar/excelize"
"github.com/mohae/deepcopy" "github.com/mohae/deepcopy"
"github.com/stretchr/testify/assert"
"github.com/360EntSecGroup-Skylar/excelize"
) )
var _ = []excelize.SheetPrOption{ var _ = []excelize.SheetPrOption{
@ -86,7 +87,8 @@ func ExampleFile_GetSheetPrOptions() {
func TestSheetPrOptions(t *testing.T) { func TestSheetPrOptions(t *testing.T) {
const sheet = "Sheet1" const sheet = "Sheet1"
for _, test := range []struct {
testData := []struct {
container excelize.SheetPrOptionPtr container excelize.SheetPrOptionPtr
nonDefault excelize.SheetPrOption nonDefault excelize.SheetPrOption
}{ }{
@ -96,66 +98,69 @@ func TestSheetPrOptions(t *testing.T) {
{new(excelize.FitToPage), excelize.FitToPage(true)}, {new(excelize.FitToPage), excelize.FitToPage(true)},
{new(excelize.AutoPageBreaks), excelize.AutoPageBreaks(true)}, {new(excelize.AutoPageBreaks), excelize.AutoPageBreaks(true)},
{new(excelize.OutlineSummaryBelow), excelize.OutlineSummaryBelow(false)}, {new(excelize.OutlineSummaryBelow), excelize.OutlineSummaryBelow(false)},
} { }
opt := test.nonDefault
t.Logf("option %T", opt) for i, test := range testData {
t.Run(fmt.Sprintf("TestData%d", i), func(t *testing.T) {
def := deepcopy.Copy(test.container).(excelize.SheetPrOptionPtr)
val1 := deepcopy.Copy(def).(excelize.SheetPrOptionPtr) opt := test.nonDefault
val2 := deepcopy.Copy(def).(excelize.SheetPrOptionPtr) t.Logf("option %T", opt)
xl := excelize.NewFile() def := deepcopy.Copy(test.container).(excelize.SheetPrOptionPtr)
// Get the default value val1 := deepcopy.Copy(def).(excelize.SheetPrOptionPtr)
if err := xl.GetSheetPrOptions(sheet, def); err != nil { val2 := deepcopy.Copy(def).(excelize.SheetPrOptionPtr)
t.Fatalf("%T: %s", opt, err)
} xl := excelize.NewFile()
// Get again and check // Get the default value
if err := xl.GetSheetPrOptions(sheet, val1); err != nil { if !assert.NoError(t, xl.GetSheetPrOptions(sheet, def), opt) {
t.Fatalf("%T: %s", opt, err) t.FailNow()
} }
if !reflect.DeepEqual(val1, def) { // Get again and check
t.Fatalf("%T: value should not have changed", opt) if !assert.NoError(t, xl.GetSheetPrOptions(sheet, val1), opt) {
} t.FailNow()
// Set the same value }
if err := xl.SetSheetPrOptions(sheet, val1); err != nil { if !assert.Equal(t, val1, def, opt) {
t.Fatalf("%T: %s", opt, err) t.FailNow()
} }
// Get again and check // Set the same value
if err := xl.GetSheetPrOptions(sheet, val1); err != nil { if !assert.NoError(t, xl.SetSheetPrOptions(sheet, val1), opt) {
t.Fatalf("%T: %s", opt, err) t.FailNow()
} }
if !reflect.DeepEqual(val1, def) { // Get again and check
t.Fatalf("%T: value should not have changed", opt) if !assert.NoError(t, xl.GetSheetPrOptions(sheet, val1), opt) {
} t.FailNow()
}
// Set a different value if !assert.Equal(t, val1, def, "%T: value should not have changed", opt) {
if err := xl.SetSheetPrOptions(sheet, test.nonDefault); err != nil { t.FailNow()
t.Fatalf("%T: %s", opt, err) }
} // Set a different value
if err := xl.GetSheetPrOptions(sheet, val1); err != nil { if !assert.NoError(t, xl.SetSheetPrOptions(sheet, test.nonDefault), opt) {
t.Fatalf("%T: %s", opt, err) t.FailNow()
} }
// Get again and compare if !assert.NoError(t, xl.GetSheetPrOptions(sheet, val1), opt) {
if err := xl.GetSheetPrOptions(sheet, val2); err != nil { t.FailNow()
t.Fatalf("%T: %s", opt, err) }
} // Get again and compare
if !reflect.DeepEqual(val2, val1) { if !assert.NoError(t, xl.GetSheetPrOptions(sheet, val2), opt) {
t.Fatalf("%T: value should not have changed", opt) t.FailNow()
} }
// Value should not be the same as the default if !assert.Equal(t, val1, val2, "%T: value should not have changed", opt) {
if reflect.DeepEqual(val1, def) { t.FailNow()
t.Fatalf("%T: value should have changed from default", opt) }
} // Value should not be the same as the default
if !assert.NotEqual(t, def, val1, "%T: value should have changed from default", opt) {
// Restore the default value t.FailNow()
if err := xl.SetSheetPrOptions(sheet, def); err != nil { }
t.Fatalf("%T: %s", opt, err) // Restore the default value
} if !assert.NoError(t, xl.SetSheetPrOptions(sheet, def), opt) {
if err := xl.GetSheetPrOptions(sheet, val1); err != nil { t.FailNow()
t.Fatalf("%T: %s", opt, err) }
} if !assert.NoError(t, xl.GetSheetPrOptions(sheet, val1), opt) {
if !reflect.DeepEqual(val1, def) { t.FailNow()
t.Fatalf("%T: value should now be the same as default", opt) }
} if !assert.Equal(t, def, val1) {
t.FailNow()
}
})
} }
} }

@ -4,6 +4,8 @@ import (
"fmt" "fmt"
"testing" "testing"
"github.com/stretchr/testify/assert"
"github.com/360EntSecGroup-Skylar/excelize" "github.com/360EntSecGroup-Skylar/excelize"
) )
@ -157,29 +159,12 @@ func TestSheetViewOptionsErrors(t *testing.T) {
xl := excelize.NewFile() xl := excelize.NewFile()
const sheet = "Sheet1" const sheet = "Sheet1"
if err := xl.GetSheetViewOptions(sheet, 0); err != nil { assert.NoError(t, xl.GetSheetViewOptions(sheet, 0))
t.Errorf("Unexpected error: %s", err) assert.NoError(t, xl.GetSheetViewOptions(sheet, -1))
} assert.Error(t, xl.GetSheetViewOptions(sheet, 1))
if err := xl.GetSheetViewOptions(sheet, -1); err != nil { assert.Error(t, xl.GetSheetViewOptions(sheet, -2))
t.Errorf("Unexpected error: %s", err) assert.NoError(t, xl.SetSheetViewOptions(sheet, 0))
} assert.NoError(t, xl.SetSheetViewOptions(sheet, -1))
if err := xl.GetSheetViewOptions(sheet, 1); err == nil { assert.Error(t, xl.SetSheetViewOptions(sheet, 1))
t.Error("Error expected but got nil") assert.Error(t, xl.SetSheetViewOptions(sheet, -2))
}
if err := xl.GetSheetViewOptions(sheet, -2); err == nil {
t.Error("Error expected but got nil")
}
if err := xl.SetSheetViewOptions(sheet, 0); err != nil {
t.Errorf("Unexpected error: %s", err)
}
if err := xl.SetSheetViewOptions(sheet, -1); err != nil {
t.Errorf("Unexpected error: %s", err)
}
if err := xl.SetSheetViewOptions(sheet, 1); err == nil {
t.Error("Error expected but got nil")
}
if err := xl.SetSheetViewOptions(sheet, -2); err == nil {
t.Error("Error expected but got nil")
}
} }

Loading…
Cancel
Save