From 32b23ef42d3ecb393e102c5f63ab5125db354435 Mon Sep 17 00:00:00 2001 From: xuri Date: Sun, 5 Sep 2021 11:59:50 +0800 Subject: This closes #998 - Support text comparison in the formula, also ref #65 - `GetCellValue`, `GetRows`, `GetCols`, `Rows` and `Cols` support to specify read cell with raw value, ref #621 - Add missing properties for the cell formula - Update the unit test for the `CalcCellValue` --- calc_test.go | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'calc_test.go') diff --git a/calc_test.go b/calc_test.go index d526b34..4c32983 100644 --- a/calc_test.go +++ b/calc_test.go @@ -2452,17 +2452,27 @@ func TestCalcWithDefinedName(t *testing.T) { } func TestCalcArithmeticOperations(t *testing.T) { + opdStack := NewStack() + for _, test := range [][]string{{"1", "text", "FALSE"}, {"text", "1", "TRUE"}} { + assert.NoError(t, calcL(test[0], test[1], opdStack)) + assert.Equal(t, test[2], opdStack.Peek().(efp.Token).TValue) + opdStack.Empty() + assert.NoError(t, calcLe(test[0], test[1], opdStack)) + assert.Equal(t, test[2], opdStack.Peek().(efp.Token).TValue) + opdStack.Empty() + } + for _, test := range [][]string{{"1", "text", "TRUE"}, {"text", "1", "FALSE"}} { + assert.NoError(t, calcG(test[0], test[1], opdStack)) + assert.Equal(t, test[2], opdStack.Peek().(efp.Token).TValue) + opdStack.Empty() + assert.NoError(t, calcGe(test[0], test[1], opdStack)) + assert.Equal(t, test[2], opdStack.Peek().(efp.Token).TValue) + opdStack.Empty() + } + err := `strconv.ParseFloat: parsing "text": invalid syntax` assert.EqualError(t, calcPow("1", "text", nil), err) assert.EqualError(t, calcPow("text", "1", nil), err) - assert.EqualError(t, calcL("1", "text", nil), err) - assert.EqualError(t, calcL("text", "1", nil), err) - assert.EqualError(t, calcLe("1", "text", nil), err) - assert.EqualError(t, calcLe("text", "1", nil), err) - assert.EqualError(t, calcG("1", "text", nil), err) - assert.EqualError(t, calcG("text", "1", nil), err) - assert.EqualError(t, calcGe("1", "text", nil), err) - assert.EqualError(t, calcGe("text", "1", nil), err) assert.EqualError(t, calcAdd("1", "text", nil), err) assert.EqualError(t, calcAdd("text", "1", nil), err) assert.EqualError(t, calcAdd("1", "text", nil), err) -- cgit v1.2.1