summaryrefslogtreecommitdiff
path: root/adjust_test.go
diff options
context:
space:
mode:
authorxuri <xuri.me@gmail.com>2020-05-22 16:53:46 +0800
committerGitHub <noreply@github.com>2020-05-22 16:53:46 +0800
commitec14de32f0c06f7a26b6b79578f666c0cc50b72c (patch)
treec6ebd61a7d9a7da5b993ffb82e4fb6c036e75d6a /adjust_test.go
parentaa7eadbffe6ae2f9f86201bbaaa4c1d1e8829cae (diff)
parent2efc7107ff30dc7f1e1a798082616ee488f99489 (diff)
Merge branch 'master' into fix/cell_lock
Diffstat (limited to 'adjust_test.go')
-rw-r--r--adjust_test.go51
1 files changed, 51 insertions, 0 deletions
diff --git a/adjust_test.go b/adjust_test.go
index 7b708ab..13e47ff 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) {
@@ -67,3 +85,36 @@ func TestAdjustHelper(t *testing.T) {
// testing adjustHelper on not exists worksheet.
assert.EqualError(t, f.adjustHelper("SheetN", rows, 0, 0), "sheet SheetN is not exist")
}
+
+func TestAdjustCalcChain(t *testing.T) {
+ f := NewFile()
+ f.CalcChain = &xlsxCalcChain{
+ C: []xlsxCalcChainC{
+ {R: "B2"},
+ },
+ }
+ assert.NoError(t, f.InsertCol("Sheet1", "A"))
+ assert.NoError(t, f.InsertRow("Sheet1", 1))
+
+ f.CalcChain.C[0].R = "invalid coordinates"
+ assert.EqualError(t, f.InsertCol("Sheet1", "A"), `cannot convert cell "invalid coordinates" to coordinates: invalid cell name "invalid coordinates"`)
+ f.CalcChain = nil
+ assert.NoError(t, f.InsertCol("Sheet1", "A"))
+}
+
+func TestCoordinatesToAreaRef(t *testing.T) {
+ f := NewFile()
+ _, err := f.coordinatesToAreaRef([]int{})
+ assert.EqualError(t, err, "coordinates length must be 4")
+ _, err = f.coordinatesToAreaRef([]int{1, -1, 1, 1})
+ assert.EqualError(t, err, "invalid cell coordinates [1, -1]")
+ _, 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")
+}
+
+func TestSortCoordinates(t *testing.T) {
+ assert.EqualError(t, sortCoordinates(make([]int, 3)), "coordinates length must be 4")
+}