CreateBigSourceDataWithBlockSize() will yield only items count + block size if the number of blocks fits max array size.

This commit is contained in:
mlemanczyk committed 2024-02-19 22:36:56 +01:00
1 parent 78467e5178
commit cb2ae350ae
1 file changed
+5 -2
@@ -190,7 +190,10 @@ namespace Recyclable.Collections.TestData
using var testData = CreateTestData(itemsCount).ToRecyclableLongList();
foreach (var blockSize in BlockSizeVariants)
{
yield return ($"long[{itemsCount}]", testData, itemsCount, blockSize);
if (IsValidBlockSize(itemsCount, blockSize))
{
yield return ($"long[{itemsCount}]", testData, itemsCount, blockSize);
}
}
}
@@ -439,7 +442,7 @@ namespace Recyclable.Collections.TestData
yield return index;
}
}
public static bool IsValidBlockSize(long itemsCount, long blockSize) => itemsCount is < 1024 || blockSize is > 8;
public static bool IsValidBlockSize(long itemsCount, long blockSize) => itemsCount is < 1024 || (itemsCount / blockSize + (itemsCount % blockSize > 0 ? 1 : 0) <= Array.MaxLength);
public static IEnumerable<int> BlockSizeVariants { get; }= new int[]
{