@@ -2266,6 +2266,7 @@ func TestCalcCellValue(t *testing.T) {
22662266 "VDB(10000,1000,5,0,1)" : "4000" ,
22672267 "VDB(10000,1000,5,1,3)" : "3840" ,
22682268 "VDB(10000,1000,5,3,5)" : "1160" ,
2269+ "VDB(10000,1000,5,3.5,5,2)" : "709.6" ,
22692270 "VDB(10000,1000,5,3,5,0.2,FALSE)" : "3600" ,
22702271 "VDB(10000,1000,5,3,5,0.2,TRUE)" : "693.633024" ,
22712272 "VDB(24000,3000,10,0,0.875,2)" : "4200" ,
@@ -5045,6 +5046,13 @@ func TestCalcVLOOKUP(t *testing.T) {
50455046 assert .Equal (t , expected [0 ], result , formula )
50465047 assert .EqualError (t , err , expected [1 ], formula )
50475048 }
5049+ argsList := list .New ()
5050+ argsList .PushBack (newStringFormulaArg ("" ))
5051+ argsList .PushBack (newMatrixFormulaArg ([][]formulaArg {{newNumberFormulaArg (1 )}}))
5052+ argsList .PushBack (newNumberFormulaArg (1 ))
5053+ argsList .PushBack (newStringFormulaArg ("" ))
5054+ _ , _ , _ , _ , err := checkHVLookupArgs ("VLOOKUP" , argsList )
5055+ assert .Equal (t , ArgError , err .Type )
50485056}
50495057
50505058func TestCalcBoolean (t * testing.T ) {
@@ -5322,6 +5330,7 @@ func TestCalcDatabase(t *testing.T) {
53225330 "DCOUNTA(A4:E4,,A1:F2)" : {"#VALUE!" , "#VALUE!" },
53235331 "DCOUNTA(A4:E10,\" x\" ,A2:F3)" : {"#VALUE!" , "#VALUE!" },
53245332 "DGET()" : {"#VALUE!" , "DGET requires 3 arguments" },
5333+ "DGET(A1,\" Profit\" ,A1)" : {"#VALUE!" , "#VALUE!" },
53255334 "DGET(A4:E5,\" Profit\" ,A1:F3)" : {"#VALUE!" , "#VALUE!" },
53265335 "DGET(A4:E10,\" Profit\" ,A1:F3)" : {"#NUM!" , "#NUM!" },
53275336 "DMAX()" : {"#VALUE!" , "DMAX requires 3 arguments" },
@@ -5475,6 +5484,7 @@ func TestCalcHLOOKUP(t *testing.T) {
54755484 }
54765485 calcError := map [string ][]string {
54775486 "HLOOKUP(INT(1),A3:A3,1,FALSE)" : {"#N/A" , "HLOOKUP no result found" },
5487+ "HLOOKUP(4,A1:E1048576,2,TRUE)" : {"#N/A" , "HLOOKUP no result found" },
54785488 }
54795489 for formula , expected := range calcError {
54805490 assert .NoError (t , f .SetCellFormula ("Sheet1" , "B10" , formula ))
@@ -6734,3 +6744,66 @@ func TestCalcCellValueCache(t *testing.T) {
67346744 }
67356745 })
67366746}
6747+
6748+ func TestCalcLookupCol (t * testing.T ) {
6749+ result := lookupCol (formulaArg {
6750+ Type : ArgMatrix ,
6751+ Matrix : [][]formulaArg {
6752+ {newNumberFormulaArg (1 ), newNumberFormulaArg (2 )},
6753+ {},
6754+ {newNumberFormulaArg (3 ), newNumberFormulaArg (4 )},
6755+ },
6756+ }, 0 )
6757+ assert .Equal (t , 3 , len (result ))
6758+ assert .Equal (t , "1" , result [0 ].Value ())
6759+ assert .Equal (t , "" , result [1 ].Value ())
6760+ assert .Equal (t , "3" , result [2 ].Value ())
6761+ }
6762+
6763+ func TestCalcLookupLinearSearch (t * testing.T ) {
6764+ lookupValue := newStringFormulaArg ("test" )
6765+ lookupArray := formulaArg {
6766+ Type : ArgString ,
6767+ Matrix : [][]formulaArg {
6768+ {newStringFormulaArg ("test" )},
6769+ },
6770+ }
6771+ matchMode := newNumberFormulaArg (0 )
6772+ searchMode := newNumberFormulaArg (1 )
6773+ idx , wasExact := lookupLinearSearch (false , lookupValue , lookupArray , matchMode , searchMode )
6774+ assert .Equal (t , 0 , idx )
6775+ assert .True (t , wasExact )
6776+ }
6777+
6778+ func TestCalcMatchMatrix (t * testing.T ) {
6779+ assert .Equal (t , formulaArg {Type : ArgNumber , Number : 2 },
6780+ calcMatchMatrix (true , 1 , & formulaCriteria {
6781+ Type : criteriaEq ,
6782+ Condition : newStringFormulaArg ("B" ),
6783+ }, [][]formulaArg {
6784+ {newStringFormulaArg ("A" )},
6785+ {newStringFormulaArg ("B" )},
6786+ {newStringFormulaArg ("C" )},
6787+ }),
6788+ )
6789+ }
6790+
6791+ func TestCalcTrendGrowthMultipleRegressionPart2 (t * testing.T ) {
6792+ calcTrendGrowthMultipleRegressionPart2 (true , false ,
6793+ [][]float64 {{1 }, {2 }, {3 }},
6794+ [][]float64 {},
6795+ [][]float64 {},
6796+ [][]float64 {{0 }},
6797+ 2.0 , 0 , 0 , 3 )
6798+ calcTrendGrowthMultipleRegressionPart2 (true , false ,
6799+ [][]float64 {{1 }, {2 }, {3 }},
6800+ [][]float64 {{0 }, {0 }, {0 }},
6801+ [][]float64 {},
6802+ [][]float64 {{0 }},
6803+ 2.0 , 0 , 1 , 3 )
6804+ }
6805+
6806+ func TestCalcTrendGrowthRegression (t * testing.T ) {
6807+ mtx := [][]float64 {}
6808+ calcTrendGrowthRegression (false , false , 0 , 0 , 0 , 0 , 0 , mtx , mtx , mtx , mtx )
6809+ }
0 commit comments