diff options
author | xuri <xuri.me@gmail.com> | 2018-01-19 20:58:26 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-19 20:58:26 +0800 |
commit | 541d29f3b2bfc62c05813a8d8725fca0a628bc81 (patch) | |
tree | 0942444e882e0f6db2aee1092150bcdb75448b85 /cell_test.go | |
parent | 50cdaed5a36f7112c2ff01504c475457f0d4944e (diff) | |
parent | 317ef65381b179b863dcd6b1f5479cc576a8376c (diff) |
Merge pull request #180 from mbresson/optimize-SetCellStyle
make SetCellStyle quicker by skipping conversions in checkCellInArea,…
Diffstat (limited to 'cell_test.go')
-rw-r--r-- | cell_test.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/cell_test.go b/cell_test.go new file mode 100644 index 0000000..2ab5413 --- /dev/null +++ b/cell_test.go @@ -0,0 +1,40 @@ +package excelize + +import "testing" + +func TestCheckCellInArea(t *testing.T) { + expectedTrueCellInAreaList := [][2]string{ + [2]string{"c2", "A1:AAZ32"}, + [2]string{"AA0", "Z0:AB1"}, + [2]string{"B9", "A1:B9"}, + [2]string{"C2", "C2:C2"}, + } + + for _, expectedTrueCellInArea := range expectedTrueCellInAreaList { + cell := expectedTrueCellInArea[0] + area := expectedTrueCellInArea[1] + + cellInArea := checkCellInArea(cell, area) + + if !cellInArea { + t.Fatalf("Expected cell %v to be in area %v, got false\n", cell, area) + } + } + + expectedFalseCellInAreaList := [][2]string{ + [2]string{"c2", "A4:AAZ32"}, + [2]string{"C4", "D6:A1"}, // weird case, but you never know + [2]string{"AEF42", "BZ40:AEF41"}, + } + + for _, expectedFalseCellInArea := range expectedFalseCellInAreaList { + cell := expectedFalseCellInArea[0] + area := expectedFalseCellInArea[1] + + cellInArea := checkCellInArea(cell, area) + + if cellInArea { + t.Fatalf("Expected cell %v not to be inside of area %v, but got true\n", cell, area) + } + } +} |