diff options
author | xuri <xuri.me@gmail.com> | 2019-06-12 08:10:33 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2019-06-12 08:10:33 +0800 |
commit | 821632cf89422b9955160a3af7f28f05a12f70f8 (patch) | |
tree | 78ed9fa1fcbee8b78bd1a396e3307f97ac38926e /adjust_test.go | |
parent | 46a3632ee0f441c8990a7205445dfdb00823a6ad (diff) |
Fix #424, refactor merged cells adjuster
Diffstat (limited to 'adjust_test.go')
-rw-r--r-- | adjust_test.go | 31 |
1 files changed, 31 insertions, 0 deletions
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") +} |