From 44a13aa402b0189b119635d2f0a26961795c6bda Mon Sep 17 00:00:00 2001 From: xuri Date: Tue, 7 Dec 2021 00:26:53 +0800 Subject: Export 7 errors so users can act differently on different type of errors --- adjust_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'adjust_test.go') diff --git a/adjust_test.go b/adjust_test.go index 3509b5d..7a482f7 100644 --- a/adjust_test.go +++ b/adjust_test.go @@ -17,7 +17,7 @@ func TestAdjustMergeCells(t *testing.T) { }, }, }, - }, rows, 0, 0), `cannot convert cell "A" to coordinates: invalid cell name "A"`) + }, rows, 0, 0), newCellNameToCoordinatesError("A", newInvalidCellNameError("A")).Error()) assert.EqualError(t, f.adjustMergeCells(&xlsxWorksheet{ MergeCells: &xlsxMergeCells{ Cells: []*xlsxMergeCell{ @@ -26,7 +26,7 @@ func TestAdjustMergeCells(t *testing.T) { }, }, }, - }, rows, 0, 0), `cannot convert cell "B" to coordinates: invalid cell name "B"`) + }, rows, 0, 0), newCellNameToCoordinatesError("B", newInvalidCellNameError("B")).Error()) assert.NoError(t, f.adjustMergeCells(&xlsxWorksheet{ MergeCells: &xlsxMergeCells{ Cells: []*xlsxMergeCell{ @@ -265,12 +265,12 @@ func TestAdjustAutoFilter(t *testing.T) { AutoFilter: &xlsxAutoFilter{ Ref: "A:B1", }, - }, rows, 0, 0), `cannot convert cell "A" to coordinates: invalid cell name "A"`) + }, rows, 0, 0), newCellNameToCoordinatesError("A", newInvalidCellNameError("A")).Error()) assert.EqualError(t, f.adjustAutoFilter(&xlsxWorksheet{ AutoFilter: &xlsxAutoFilter{ Ref: "A1:B", }, - }, rows, 0, 0), `cannot convert cell "B" to coordinates: invalid cell name "B"`) + }, rows, 0, 0), newCellNameToCoordinatesError("B", newInvalidCellNameError("B")).Error()) } func TestAdjustHelper(t *testing.T) { @@ -281,8 +281,8 @@ func TestAdjustHelper(t *testing.T) { f.Sheet.Store("xl/worksheets/sheet2.xml", &xlsxWorksheet{ AutoFilter: &xlsxAutoFilter{Ref: "A1:B"}}) // testing adjustHelper with illegal cell coordinates. - assert.EqualError(t, f.adjustHelper("Sheet1", rows, 0, 0), `cannot convert cell "A" to coordinates: invalid cell name "A"`) - assert.EqualError(t, f.adjustHelper("Sheet2", rows, 0, 0), `cannot convert cell "B" to coordinates: invalid cell name "B"`) + assert.EqualError(t, f.adjustHelper("Sheet1", rows, 0, 0), newCellNameToCoordinatesError("A", newInvalidCellNameError("A")).Error()) + assert.EqualError(t, f.adjustHelper("Sheet2", rows, 0, 0), newCellNameToCoordinatesError("B", newInvalidCellNameError("B")).Error()) // testing adjustHelper on not exists worksheet. assert.EqualError(t, f.adjustHelper("SheetN", rows, 0, 0), "sheet SheetN is not exist") } @@ -298,7 +298,7 @@ func TestAdjustCalcChain(t *testing.T) { assert.NoError(t, f.InsertRow("Sheet1", 1)) f.CalcChain.C[1].R = "invalid coordinates" - assert.EqualError(t, f.InsertCol("Sheet1", "A"), `cannot convert cell "invalid coordinates" to coordinates: invalid cell name "invalid coordinates"`) + assert.EqualError(t, f.InsertCol("Sheet1", "A"), newCellNameToCoordinatesError("invalid coordinates", newInvalidCellNameError("invalid coordinates")).Error()) f.CalcChain = nil assert.NoError(t, f.InsertCol("Sheet1", "A")) } -- cgit v1.2.1