summaryrefslogtreecommitdiff
path: root/calc_test.go
diff options
context:
space:
mode:
authorxuri <xuri.me@gmail.com>2020-11-10 23:48:09 +0800
committerxuri <xuri.me@gmail.com>2020-11-11 01:03:56 +0800
commit2514bb16c682679485dfb5298e1a5797b97bdcd7 (patch)
treea53f0e7de3fa76b6462e2016e9a734cbd46b3a42 /calc_test.go
parent5dd0b4aec2931079e064f1fb393b034ce4934540 (diff)
Fix #724, standardize variable naming and update unit tests
Diffstat (limited to 'calc_test.go')
-rw-r--r--calc_test.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/calc_test.go b/calc_test.go
index c6a7dbc..9bf6e08 100644
--- a/calc_test.go
+++ b/calc_test.go
@@ -7,6 +7,7 @@ import (
"testing"
"github.com/stretchr/testify/assert"
+ "github.com/xuri/efp"
)
func TestCalcCellValue(t *testing.T) {
@@ -854,6 +855,18 @@ func TestCalcCellValue(t *testing.T) {
}
+func TestCalculate(t *testing.T) {
+ err := `strconv.ParseFloat: parsing "string": invalid syntax`
+ opd := NewStack()
+ opd.Push(efp.Token{TValue: "string"})
+ opt := efp.Token{TValue: "-", TType: efp.TokenTypeOperatorPrefix}
+ assert.EqualError(t, calculate(opd, opt), err)
+ opd.Push(efp.Token{TValue: "string"})
+ opd.Push(efp.Token{TValue: "string"})
+ opt = efp.Token{TValue: "-", TType: efp.TokenTypeOperatorInfix}
+ assert.EqualError(t, calculate(opd, opt), err)
+}
+
func TestCalcCellValueWithDefinedName(t *testing.T) {
cellData := [][]interface{}{
{"A1 value", "B1 value", nil},