summaryrefslogtreecommitdiff
path: root/cell_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'cell_test.go')
-rw-r--r--cell_test.go30
1 files changed, 27 insertions, 3 deletions
diff --git a/cell_test.go b/cell_test.go
index 653aaab..b030622 100644
--- a/cell_test.go
+++ b/cell_test.go
@@ -4,11 +4,13 @@ import (
"fmt"
"path/filepath"
"testing"
+ "time"
"github.com/stretchr/testify/assert"
)
func TestCheckCellInArea(t *testing.T) {
+ f := NewFile()
expectedTrueCellInAreaList := [][2]string{
{"c2", "A1:AAZ32"},
{"B9", "A1:B9"},
@@ -18,7 +20,7 @@ func TestCheckCellInArea(t *testing.T) {
for _, expectedTrueCellInArea := range expectedTrueCellInAreaList {
cell := expectedTrueCellInArea[0]
area := expectedTrueCellInArea[1]
- ok, err := checkCellInArea(cell, area)
+ ok, err := f.checkCellInArea(cell, area)
assert.NoError(t, err)
assert.Truef(t, ok,
"Expected cell %v to be in area %v, got false\n", cell, area)
@@ -33,13 +35,17 @@ func TestCheckCellInArea(t *testing.T) {
for _, expectedFalseCellInArea := range expectedFalseCellInAreaList {
cell := expectedFalseCellInArea[0]
area := expectedFalseCellInArea[1]
- ok, err := checkCellInArea(cell, area)
+ ok, err := f.checkCellInArea(cell, area)
assert.NoError(t, err)
assert.Falsef(t, ok,
"Expected cell %v not to be inside of area %v, but got true\n", cell, area)
}
- ok, err := checkCellInArea("AA0", "Z0:AB1")
+ ok, err := f.checkCellInArea("A1", "A:B")
+ assert.EqualError(t, err, `cannot convert cell "A" to coordinates: invalid cell name "A"`)
+ assert.False(t, ok)
+
+ ok, err = f.checkCellInArea("AA0", "Z0:AB1")
assert.EqualError(t, err, `cannot convert cell "AA0" to coordinates: invalid cell name "AA0"`)
assert.False(t, ok)
}
@@ -73,6 +79,24 @@ func TestSetCellFloat(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, "123.42", val, "A1 should be 123.42")
})
+ f := NewFile()
+ assert.EqualError(t, f.SetCellFloat(sheet, "A", 123.42, -1, 64), `cannot convert cell "A" to coordinates: invalid cell name "A"`)
+}
+
+func TestSetCellValue(t *testing.T) {
+ f := NewFile()
+ assert.EqualError(t, f.SetCellValue("Sheet1", "A", time.Now().UTC()), `cannot convert cell "A" to coordinates: invalid cell name "A"`)
+ assert.EqualError(t, f.SetCellValue("Sheet1", "A", time.Duration(1e13)), `cannot convert cell "A" to coordinates: invalid cell name "A"`)
+}
+
+func TestSetCellBool(t *testing.T) {
+ f := NewFile()
+ assert.EqualError(t, f.SetCellBool("Sheet1", "A", true), `cannot convert cell "A" to coordinates: invalid cell name "A"`)
+}
+
+func TestGetCellFormula(t *testing.T) {
+ f := NewFile()
+ f.GetCellFormula("Sheet", "A1")
}
func ExampleFile_SetCellFloat() {