2018-01-19 17:32:54 +08:00
|
|
|
package excelize
|
|
|
|
|
2018-12-27 18:51:44 +08:00
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
2018-01-19 17:32:54 +08:00
|
|
|
|
|
|
|
func TestCheckCellInArea(t *testing.T) {
|
|
|
|
expectedTrueCellInAreaList := [][2]string{
|
2018-01-31 11:12:43 +08:00
|
|
|
{"c2", "A1:AAZ32"},
|
|
|
|
{"AA0", "Z0:AB1"},
|
|
|
|
{"B9", "A1:B9"},
|
|
|
|
{"C2", "C2:C2"},
|
2018-01-19 17:32:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, expectedTrueCellInArea := range expectedTrueCellInAreaList {
|
|
|
|
cell := expectedTrueCellInArea[0]
|
|
|
|
area := expectedTrueCellInArea[1]
|
|
|
|
|
2018-12-27 18:51:44 +08:00
|
|
|
assert.True(t, checkCellInArea(cell, area),
|
|
|
|
"Expected cell %v to be in area %v, got false\n", cell, area)
|
2018-01-19 17:32:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
expectedFalseCellInAreaList := [][2]string{
|
2018-01-31 11:12:43 +08:00
|
|
|
{"c2", "A4:AAZ32"},
|
|
|
|
{"C4", "D6:A1"}, // weird case, but you never know
|
|
|
|
{"AEF42", "BZ40:AEF41"},
|
2018-01-19 17:32:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, expectedFalseCellInArea := range expectedFalseCellInAreaList {
|
|
|
|
cell := expectedFalseCellInArea[0]
|
|
|
|
area := expectedFalseCellInArea[1]
|
|
|
|
|
2018-12-27 18:51:44 +08:00
|
|
|
assert.False(t, checkCellInArea(cell, area),
|
|
|
|
"Expected cell %v not to be inside of area %v, but got true\n", cell, area)
|
2018-01-19 17:32:54 +08:00
|
|
|
}
|
|
|
|
}
|