diff options
| author | xuri <xuri.me@gmail.com> | 2021-09-05 11:59:50 +0800 |
|---|---|---|
| committer | xuri <xuri.me@gmail.com> | 2021-09-05 11:59:50 +0800 |
| commit | 32b23ef42d3ecb393e102c5f63ab5125db354435 (patch) | |
| tree | e73ec4e2e062d15ca6d53407039ddb3004942995 /calc_test.go | |
| parent | 2616aa88cb2b1e45c03ada60093f4dfe7fabfb87 (diff) | |
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`
Diffstat (limited to 'calc_test.go')
| -rw-r--r-- | calc_test.go | 26 |
1 files changed, 18 insertions, 8 deletions
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) |
