Skip to content

Commit

Permalink
Added guard against negative index values
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementVaillantCodit committed Jul 12, 2024
1 parent 6b0f144 commit 3db9daf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Arcus.Testing.Assert/AssertCsv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public AssertCsvOptions IgnoreColumn(string headerName)
/// <param name="index">The zero-based index of the column that should be ignored.</param>
public AssertCsvOptions IgnoreColumn(int index)
{
if (index < 0)
{
throw new ArgumentOutOfRangeException(nameof(index), $"Requires a positive '{nameof(index)}' value when adding an ignored column of a CSV table");
}

_ignoredColumnIndexes.Add(index);
return this;
}
Expand Down Expand Up @@ -392,7 +397,7 @@ private static void EnsureOnlyIgnoreColumnsOnPresentHeaders(CsvTable expected, C
$"please provide such headers in the contents, or remove the 'options.{nameof(AssertCsvOptions.IgnoreColumn)}' call(s)")
.ToString());
}

if (options.IgnoredColumnIndexes.Count > 0 && options.ColumnOrder == AssertCsvOrder.Ignore)
{
throw new EqualAssertionException(
Expand Down

0 comments on commit 3db9daf

Please sign in to comment.