Skip to content

Commit

Permalink
#817 - Match functions compares null values as exact match
Browse files Browse the repository at this point in the history
  • Loading branch information
swmal committed Mar 15, 2023
1 parent 0ddcd79 commit 8efeb59
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public override CompileResult Execute(IEnumerable<FunctionArgument> arguments, P
var matchResult = IsMatch(searchedValue, navigator.CurrentValue);

// For all match types, if the match result indicated equality, return the index (1 based)
if (matchResult == 0)
if (searchedValue != null && matchResult == 0)
{
return CreateResult(navigator.Index + 1, DataType.Integer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,20 @@ public void Match_Without_ExactMatch()

Assert.AreEqual(ExcelErrorValue.Create(eErrorType.NA), _worksheet.Cells["A4"].Value);
}

[TestMethod]
public void Match_With_ExactMatch_ShouldNotTreatNullValuesAsAMatch()
{
_worksheet.Cells["A1"].Value = "test";
_worksheet.Cells["A2"].Value = "value_to_match";
_worksheet.Cells["A3"].Value = "test";

//_worksheet.Cells["A4"].Value
_worksheet.Cells["A4"].Formula = "MATCH(B1, C1:C2, 0)";

_worksheet.Calculate();

Assert.AreEqual(ExcelErrorValue.Create(eErrorType.NA), _worksheet.Cells["A4"].Value);
}
}
}

0 comments on commit 8efeb59

Please sign in to comment.