From 2514bb16c682679485dfb5298e1a5797b97bdcd7 Mon Sep 17 00:00:00 2001 From: xuri Date: Tue, 10 Nov 2020 23:48:09 +0800 Subject: Fix #724, standardize variable naming and update unit tests --- calc_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'calc_test.go') 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}, -- cgit v1.2.1