2018-01-19 17:32:54 +08:00
|
|
|
package excelize
|
|
|
|
|
2018-12-27 18:51:44 +08:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
2018-01-19 17:32:54 +08:00
|
|
|
|
2018-12-27 18:51:44 +08:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestAxisLowerOrEqualThanIsTrue(t *testing.T) {
|
2018-01-19 17:32:54 +08:00
|
|
|
trueExpectedInputList := [][2]string{
|
2018-01-31 11:12:43 +08:00
|
|
|
{"A", "B"},
|
|
|
|
{"A", "AA"},
|
|
|
|
{"B", "AA"},
|
|
|
|
{"BC", "ABCD"},
|
|
|
|
{"1", "2"},
|
|
|
|
{"2", "11"},
|
2018-01-19 17:32:54 +08:00
|
|
|
}
|
|
|
|
|
2018-12-27 18:51:44 +08:00
|
|
|
for i, trueExpectedInput := range trueExpectedInputList {
|
|
|
|
t.Run(fmt.Sprintf("TestData%d", i), func(t *testing.T) {
|
|
|
|
assert.True(t, axisLowerOrEqualThan(trueExpectedInput[0], trueExpectedInput[1]))
|
|
|
|
})
|
2018-01-19 17:32:54 +08:00
|
|
|
}
|
2018-12-27 18:51:44 +08:00
|
|
|
}
|
2018-01-19 17:32:54 +08:00
|
|
|
|
2018-12-27 18:51:44 +08:00
|
|
|
func TestAxisLowerOrEqualThanIsFalse(t *testing.T) {
|
2018-01-19 17:32:54 +08:00
|
|
|
falseExpectedInputList := [][2]string{
|
2018-01-31 11:12:43 +08:00
|
|
|
{"B", "A"},
|
|
|
|
{"AA", "A"},
|
|
|
|
{"AA", "B"},
|
|
|
|
{"ABCD", "AB"},
|
|
|
|
{"2", "1"},
|
|
|
|
{"11", "2"},
|
2018-01-19 17:32:54 +08:00
|
|
|
}
|
|
|
|
|
2018-12-27 18:51:44 +08:00
|
|
|
for i, falseExpectedInput := range falseExpectedInputList {
|
|
|
|
t.Run(fmt.Sprintf("TestData%d", i), func(t *testing.T) {
|
|
|
|
assert.False(t, axisLowerOrEqualThan(falseExpectedInput[0], falseExpectedInput[1]))
|
|
|
|
})
|
2018-01-19 17:32:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestGetCellColRow(t *testing.T) {
|
2018-12-27 18:51:44 +08:00
|
|
|
cellExpectedColRowList := [][3]string{
|
|
|
|
{"C220", "C", "220"},
|
|
|
|
{"aaef42", "aaef", "42"},
|
|
|
|
{"bonjour", "bonjour", ""},
|
|
|
|
{"59", "", "59"},
|
|
|
|
{"", "", ""},
|
2018-01-19 17:32:54 +08:00
|
|
|
}
|
|
|
|
|
2018-12-27 18:51:44 +08:00
|
|
|
for i, test := range cellExpectedColRowList {
|
|
|
|
t.Run(fmt.Sprintf("TestData%d", i), func(t *testing.T) {
|
|
|
|
col, row := getCellColRow(test[0])
|
|
|
|
assert.Equal(t, test[1], col, "Unexpected col")
|
|
|
|
assert.Equal(t, test[2], row, "Unexpected row")
|
|
|
|
})
|
2018-01-19 17:32:54 +08:00
|
|
|
}
|
|
|
|
}
|