Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/BenchmarkDotNet/Code/ArrayParam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ namespace BenchmarkDotNet.Code
internal static class ArrayParam
{
public static string GetDisplayString(Array array)
=> $"{array.GetType().GetElementType()?.GetDisplayName()}[{array.Length}]";
{
string dimensionRepr = string.Join(", ", Enumerable.Range(0, array.Rank).Select(array.GetLength));

return $"{array.GetType().GetElementType()?.GetDisplayName()}[{dimensionRepr}]";
}
}

public class ArrayParam<T> : IParam
Expand Down
27 changes: 27 additions & 0 deletions tests/BenchmarkDotNet.IntegrationTests/ArgumentsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,33 @@ public void AcceptsArrays2(int[] arr)
}
}

[Theory, MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
public void MultidimensionalArraysAreProperlyDisplayed(IToolchain toolchain)
{
var summary = CanExecute<WithMultidimensionalArrayArgument>(toolchain);

Assert.Equal(
"Int32[2, 3]",
summary.Table.Columns.Where(col => col.Header == "arr").First().Content[0]
);
}

public class WithMultidimensionalArrayArgument
{
public IEnumerable<int[,]> GetArrays()
{
yield return new int[,] { { 1, 2, 3 }, { 4, 5, 6 } };
}

[Benchmark]
[ArgumentsSource(nameof(GetArrays))]
public void AcceptsMultidimensionalArray(int[,] arr)
{
if (arr.Length == 0)
throw new ArgumentException("Incorrect length");
}
}

[Theory, MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)]
public void VeryBigIntegersAreSupported(IToolchain toolchain) => CanExecute<WithVeryBigInteger>(toolchain);

Expand Down