You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Huge refactorig for consistent col/row numbering (#356)
* Huge refactorig for consistent col/row numbering
Started from simply changing ToALphaString()/TitleToNumber() logic and related fixes.
But have to go deeper, do fixes, after do related fixes and again and again.
Major improvements:
1. Tests made stronger again (But still be weak).
2. "Empty" returns for incorrect input replaces with panic.
3. Check for correct col/row/cell naming & addressing by default.
4. Removed huge amount of duplicated code.
5. Removed ToALphaString(), TitleToNumber() and it helpers functions at all,
and replaced with SplitCellName(), JoinCellName(), ColumnNameToNumber(), ColumnNumberToName(), CellNameToCoordinates(), CoordinatesToCellName().
6. Minor fixes for internal variable naming for code readability (ex. col, row for input params, colIdx, rowIdx for slice indexes etc).
* Formatting fixes
6 years ago
|
|
|
package excelize
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestNewInvalidColNameError(t *testing.T) {
|
|
|
|
assert.EqualError(t, newInvalidColumnNameError("A"), "invalid column name \"A\"")
|
|
|
|
assert.EqualError(t, newInvalidColumnNameError(""), "invalid column name \"\"")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNewInvalidRowNumberError(t *testing.T) {
|
|
|
|
assert.EqualError(t, newInvalidRowNumberError(0), "invalid row number 0")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNewInvalidCellNameError(t *testing.T) {
|
|
|
|
assert.EqualError(t, newInvalidCellNameError("A"), "invalid cell name \"A\"")
|
|
|
|
assert.EqualError(t, newInvalidCellNameError(""), "invalid cell name \"\"")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNewInvalidExcelDateError(t *testing.T) {
|
|
|
|
assert.EqualError(t, newInvalidExcelDateError(-1), "invalid date value -1.000000, negative values are not supported supported")
|
|
|
|
}
|