From 821632cf89422b9955160a3af7f28f05a12f70f8 Mon Sep 17 00:00:00 2001 From: xuri Date: Wed, 12 Jun 2019 08:10:33 +0800 Subject: Fix #424, refactor merged cells adjuster --- adjust_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'adjust_test.go') diff --git a/adjust_test.go b/adjust_test.go index 28432bc..364a8b8 100644 --- a/adjust_test.go +++ b/adjust_test.go @@ -27,6 +27,24 @@ func TestAdjustMergeCells(t *testing.T) { }, }, }, rows, 0, 0), `cannot convert cell "B" to coordinates: invalid cell name "B"`) + assert.NoError(t, f.adjustMergeCells(&xlsxWorksheet{ + MergeCells: &xlsxMergeCells{ + Cells: []*xlsxMergeCell{ + { + Ref: "A1:B1", + }, + }, + }, + }, rows, 1, -1)) + assert.NoError(t, f.adjustMergeCells(&xlsxWorksheet{ + MergeCells: &xlsxMergeCells{ + Cells: []*xlsxMergeCell{ + { + Ref: "A1:A2", + }, + }, + }, + }, columns, 1, -1)) } func TestAdjustAutoFilter(t *testing.T) { @@ -83,3 +101,16 @@ func TestAdjustCalcChain(t *testing.T) { f.CalcChain = nil assert.NoError(t, f.InsertCol("Sheet1", "A")) } + +func TestCoordinatesToAreaRef(t *testing.T) { + f := NewFile() + ref, err := f.coordinatesToAreaRef([]int{}) + assert.EqualError(t, err, "coordinates length must be 4") + ref, err = f.coordinatesToAreaRef([]int{1, -1, 1, 1}) + assert.EqualError(t, err, "invalid cell coordinates [1, -1]") + ref, err = f.coordinatesToAreaRef([]int{1, 1, 1, -1}) + assert.EqualError(t, err, "invalid cell coordinates [1, -1]") + ref, err = f.coordinatesToAreaRef([]int{1, 1, 1, 1}) + assert.NoError(t, err) + assert.EqualValues(t, ref, "A1:A1") +} -- cgit v1.2.1