From b33e39369aa3898d2f6e079240545f9d84abec73 Mon Sep 17 00:00:00 2001 From: jaby Date: Fri, 10 Dec 2021 09:48:02 +0100 Subject: This closes #1090 (#1092) Keep track of operators per function --- calc_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'calc_test.go') diff --git a/calc_test.go b/calc_test.go index 50f8023..a2b1294 100644 --- a/calc_test.go +++ b/calc_test.go @@ -3787,3 +3787,23 @@ func TestGetYearDays(t *testing.T) { assert.Equal(t, data[2], getYearDays(data[0], data[1])) } } + +func TestNestedFunctionsWithOperators(t *testing.T) { + f := NewFile() + formulaList := map[string]string{ + `=LEN("KEEP")`: "4", + `=LEN("REMOVEKEEP") - LEN("REMOVE")`: "4", + `=RIGHT("REMOVEKEEP", 4)`: "KEEP", + `=RIGHT("REMOVEKEEP", 10 - 6))`: "KEEP", + `=RIGHT("REMOVEKEEP", LEN("REMOVEKEEP") - 6)`: "KEEP", + `=RIGHT("REMOVEKEEP", LEN("REMOVEKEEP") - LEN("REMOV") - 1)`: "KEEP", + `=RIGHT("REMOVEKEEP", 10 - LEN("REMOVE"))`: "KEEP", + `=RIGHT("REMOVEKEEP", LEN("REMOVEKEEP") - LEN("REMOVE"))`: "KEEP", + } + for formula, expected := range formulaList { + assert.NoError(t, f.SetCellFormula("Sheet1", "E1", formula)) + result, err := f.CalcCellValue("Sheet1", "E1") + assert.NoError(t, err, formula) + assert.Equal(t, expected, result, formula) + } +} -- cgit v1.2.1