summaryrefslogtreecommitdiff
path: root/errors_test.go
diff options
context:
space:
mode:
authorVeniamin Albaev <albenik@gmail.com>2019-03-19 19:14:41 +0300
committerxuri <xuri.me@gmail.com>2019-03-20 00:14:41 +0800
commitdc01264562e6e88d77a28042408029770ea32df4 (patch)
treef3d8fd1627fb71676bab59fe2fa1c9b076b360d8 /errors_test.go
parent092f16c744c40e85be5cf6128dfb35c96e7df78b (diff)
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
Diffstat (limited to 'errors_test.go')
-rw-r--r--errors_test.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/errors_test.go b/errors_test.go
new file mode 100644
index 0000000..89d241c
--- /dev/null
+++ b/errors_test.go
@@ -0,0 +1,21 @@
+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 \"\"")
+}