Skip to content

Commit

Permalink
Improve indexers test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
andreise committed Jan 13, 2024
1 parent 74abc2d commit 29b68dd
Show file tree
Hide file tree
Showing 8 changed files with 233 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ namespace PrimeFuncPack.Core.Tests;
partial class FlatArrayBuilderTest
{
[Theory]
[InlineData(int.MinValue)]
[InlineData(int.MinValue + 1)]
[InlineData(MinusFifteen)]
[InlineData(-1)]
[InlineData(0)]
[InlineData(1)]
[InlineData(PlusFifteen)]
[InlineData(int.MaxValue - 1)]
[InlineData(int.MaxValue)]
public void Indexer_SourceIsDefault_ExpectIndexOutOfRangeException(int index)
{
var source = new FlatArray<StructType>.Builder();
Expand Down Expand Up @@ -43,10 +47,42 @@ public void Indexer_IndexIsInRange_ExpectItemIsFromSourceItemsByIndex(
}

[Theory]
// Effective Length: 1, Inner array length: 1
[InlineData(int.MinValue, 1, SomeString)]
[InlineData(int.MinValue + 1, 1, SomeString)]
[InlineData(MinusFifteen, 1, SomeString)]
[InlineData(-1, 1, SomeString)]
[InlineData(1, 1, SomeString)]
[InlineData(1, 1, AnotherString, SomeString)]
[InlineData(5, 2, EmptyString, TabString)]
[InlineData(PlusFifteen, 1, SomeString)]
[InlineData(int.MaxValue - 1, 1, SomeString)]
[InlineData(int.MaxValue, 1, SomeString)]
// Effective Length: 1, Inner array length: 2
[InlineData(int.MinValue, 1, EmptyString, AnotherString)]
[InlineData(int.MinValue + 1, 1, EmptyString, AnotherString)]
[InlineData(MinusFifteen, 1, EmptyString, AnotherString)]
[InlineData(-1, 1, EmptyString, AnotherString)]
[InlineData(1, 1, EmptyString, AnotherString)]
[InlineData(PlusFifteen, 1, EmptyString, AnotherString)]
[InlineData(int.MaxValue - 1, 1, EmptyString, AnotherString)]
[InlineData(int.MaxValue, 1, EmptyString, AnotherString)]
// Effective Length: 2, Inner array length: 2
[InlineData(int.MinValue, 2, EmptyString, SomeString)]
[InlineData(int.MinValue + 1, 2, EmptyString, SomeString)]
[InlineData(MinusFifteen, 2, EmptyString, SomeString)]
[InlineData(-1, 2, EmptyString, SomeString)]
[InlineData(2, 2, EmptyString, SomeString)]
[InlineData(PlusFifteen, 2, EmptyString, SomeString)]
[InlineData(int.MaxValue - 1, 2, EmptyString, SomeString)]
[InlineData(int.MaxValue, 2, EmptyString, SomeString)]
// Effective Length: 3, Inner array length: 3
[InlineData(int.MinValue, 3, LowerSomeString, null, SomeString)]
[InlineData(int.MinValue + 1, 3, LowerSomeString, null, SomeString)]
[InlineData(MinusFifteen, 3, LowerSomeString, null, SomeString)]
[InlineData(-1, 3, LowerSomeString, null, SomeString)]
[InlineData(3, 3, LowerSomeString, null, SomeString)]
[InlineData(PlusFifteen, 3, LowerSomeString, null, SomeString)]
[InlineData(int.MaxValue - 1, 3, LowerSomeString, null, SomeString)]
[InlineData(int.MaxValue, 3, LowerSomeString, null, SomeString)]
public void Indexer_IndexIsOutOfRange_ExpectIndexOutOfRangeException(
int index, int sourceLength, params string?[] sourceItems)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ partial class FlatArrayBuilderTest
[InlineData(0)]
[InlineData(1)]
[InlineData(PlusFifteen)]
[InlineData(int.MaxValue - 1)]
[InlineData(int.MaxValue)]
public void IndexerRef_IndexFromEnd_SourceIsDefault_ExpectIndexOutOfRangeException(int indexFromEnd)
{
var fromEnd = Index.FromEnd(indexFromEnd);
Expand Down Expand Up @@ -42,12 +44,26 @@ public void IndexerRef_IndexFromEnd_IndexIsInRange_ExpectItemIsFromSourceItemsBy
}

[Theory]
// Effective Length: 1, Inner array length: 1
[InlineData(0, 1, SomeString)]
[InlineData(2, 1, SomeString)]
[InlineData(int.MaxValue - 1, 1, SomeString)]
[InlineData(int.MaxValue, 1, SomeString)]
// Effective Length: 1, Inner array length: 2
[InlineData(0, 1, EmptyString, AnotherString)]
[InlineData(2, 1, EmptyString, AnotherString)]
[InlineData(int.MaxValue - 1, 1, EmptyString, AnotherString)]
[InlineData(int.MaxValue, 1, EmptyString, AnotherString)]
// Effective Length: 2, Inner array length: 2
[InlineData(0, 2, EmptyString, SomeString)]
[InlineData(3, 2, EmptyString, SomeString)]
[InlineData(int.MaxValue - 1, 2, EmptyString, SomeString)]
[InlineData(int.MaxValue, 2, EmptyString, SomeString)]
// Effective Length: 3, Inner array length: 3
[InlineData(0, 3, LowerSomeString, null, SomeString)]
[InlineData(4, 3, LowerSomeString, null, SomeString)]
[InlineData(int.MaxValue - 1, 3, LowerSomeString, null, SomeString)]
[InlineData(int.MaxValue, 3, LowerSomeString, null, SomeString)]
public void IndexerRef_IndexFromEnd_IndexIsOutOfRange_ExpectIndexOutOfRangeException(
int indexFromEnd, int sourceLength, params string?[] sourceItems)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ partial class FlatArrayBuilderTest
[InlineData(0)]
[InlineData(1)]
[InlineData(PlusFifteen)]
[InlineData(int.MaxValue - 1)]
[InlineData(int.MaxValue)]
public void IndexerRef_IndexFromStart_SourceIsDefault_ExpectIndexOutOfRangeException(int index)
{
var fromStart = Index.FromStart(index);
Expand Down Expand Up @@ -45,9 +47,26 @@ public void IndexerRef_IndexFromStart_IndexIsInRange_ExpectItemIsFromSourceItems
}

[Theory]
// Effective Length: 1, Inner array length: 1
[InlineData(1, 1, SomeString)]
[InlineData(1, 1, AnotherString, SomeString)]
[InlineData(5, 2, EmptyString, TabString)]
[InlineData(PlusFifteen, 1, SomeString)]
[InlineData(int.MaxValue - 1, 1, SomeString)]
[InlineData(int.MaxValue, 1, SomeString)]
// Effective Length: 1, Inner array length: 2
[InlineData(1, 1, EmptyString, AnotherString)]
[InlineData(PlusFifteen, 1, EmptyString, AnotherString)]
[InlineData(int.MaxValue - 1, 1, EmptyString, AnotherString)]
[InlineData(int.MaxValue, 1, EmptyString, AnotherString)]
// Effective Length: 2, Inner array length: 2
[InlineData(2, 2, EmptyString, SomeString)]
[InlineData(PlusFifteen, 2, EmptyString, SomeString)]
[InlineData(int.MaxValue - 1, 2, EmptyString, SomeString)]
[InlineData(int.MaxValue, 2, EmptyString, SomeString)]
// Effective Length: 3, Inner array length: 3
[InlineData(3, 3, LowerSomeString, null, SomeString)]
[InlineData(PlusFifteen, 3, LowerSomeString, null, SomeString)]
[InlineData(int.MaxValue - 1, 3, LowerSomeString, null, SomeString)]
[InlineData(int.MaxValue, 3, LowerSomeString, null, SomeString)]
public void IndexerRef_IndexFromStart_IndexIsOutOfRange_ExpectIndexOutOfRangeException(
int index, int sourceLength, params string?[] sourceItems)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ namespace PrimeFuncPack.Core.Tests;
partial class FlatArrayBuilderTest
{
[Theory]
[InlineData(int.MinValue)]
[InlineData(int.MinValue + 1)]
[InlineData(MinusFifteen)]
[InlineData(-1)]
[InlineData(0)]
[InlineData(1)]
[InlineData(PlusFifteen)]
[InlineData(int.MaxValue - 1)]
[InlineData(int.MaxValue)]
public void IndexerRef_SourceIsDefault_ExpectIndexOutOfRangeException(int index)
{
var source = new FlatArray<StructType>.Builder();
Expand Down Expand Up @@ -43,10 +47,42 @@ public void IndexerRef_IndexIsInRange_ExpectItemIsFromSourceItemsByIndex(
}

[Theory]
// Effective Length: 1, Inner array length: 1
[InlineData(int.MinValue, 1, SomeString)]
[InlineData(int.MinValue + 1, 1, SomeString)]
[InlineData(MinusFifteen, 1, SomeString)]
[InlineData(-1, 1, SomeString)]
[InlineData(1, 1, SomeString)]
[InlineData(1, 1, AnotherString, SomeString)]
[InlineData(5, 2, EmptyString, TabString)]
[InlineData(PlusFifteen, 1, SomeString)]
[InlineData(int.MaxValue - 1, 1, SomeString)]
[InlineData(int.MaxValue, 1, SomeString)]
// Effective Length: 1, Inner array length: 2
[InlineData(int.MinValue, 1, EmptyString, AnotherString)]
[InlineData(int.MinValue + 1, 1, EmptyString, AnotherString)]
[InlineData(MinusFifteen, 1, EmptyString, AnotherString)]
[InlineData(-1, 1, EmptyString, AnotherString)]
[InlineData(1, 1, EmptyString, AnotherString)]
[InlineData(PlusFifteen, 1, EmptyString, AnotherString)]
[InlineData(int.MaxValue - 1, 1, EmptyString, AnotherString)]
[InlineData(int.MaxValue, 1, EmptyString, AnotherString)]
// Effective Length: 2, Inner array length: 2
[InlineData(int.MinValue, 2, EmptyString, SomeString)]
[InlineData(int.MinValue + 1, 2, EmptyString, SomeString)]
[InlineData(MinusFifteen, 2, EmptyString, SomeString)]
[InlineData(-1, 2, EmptyString, SomeString)]
[InlineData(2, 2, EmptyString, SomeString)]
[InlineData(PlusFifteen, 2, EmptyString, SomeString)]
[InlineData(int.MaxValue - 1, 2, EmptyString, SomeString)]
[InlineData(int.MaxValue, 2, EmptyString, SomeString)]
// Effective Length: 3, Inner array length: 3
[InlineData(int.MinValue, 3, LowerSomeString, null, SomeString)]
[InlineData(int.MinValue + 1, 3, LowerSomeString, null, SomeString)]
[InlineData(MinusFifteen, 3, LowerSomeString, null, SomeString)]
[InlineData(-1, 3, LowerSomeString, null, SomeString)]
[InlineData(3, 3, LowerSomeString, null, SomeString)]
[InlineData(PlusFifteen, 3, LowerSomeString, null, SomeString)]
[InlineData(int.MaxValue - 1, 3, LowerSomeString, null, SomeString)]
[InlineData(int.MaxValue, 3, LowerSomeString, null, SomeString)]
public void IndexerRef_IndexIsOutOfRange_ExpectIndexOutOfRangeException(
int index, int sourceLength, params string?[] sourceItems)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ namespace PrimeFuncPack.Core.Tests;
partial class FlatArrayTest
{
[Theory]
[InlineData(int.MinValue)]
[InlineData(int.MinValue + 1)]
[InlineData(MinusFifteen)]
[InlineData(MinusOne)]
[InlineData(Zero)]
[InlineData(One)]
[InlineData(-1)]
[InlineData(0)]
[InlineData(1)]
[InlineData(PlusFifteen)]
[InlineData(int.MaxValue - 1)]
[InlineData(int.MaxValue)]
public void Indexer_SourceIsDefault_ExpectIndexOutOfRangeException(int index)
{
var source = default(FlatArray<RefType>);
Expand Down Expand Up @@ -46,10 +50,42 @@ public void Indexer_IndexIsInRange_ExpectItemIsFromSourceItemsByIndex(
}

[Theory]
// Effective Length: 1, Inner array length: 1
[InlineData(int.MinValue, 1, SomeString)]
[InlineData(int.MinValue + 1, 1, SomeString)]
[InlineData(MinusFifteen, 1, SomeString)]
[InlineData(-1, 1, SomeString)]
[InlineData(1, 1, SomeString)]
[InlineData(PlusFifteen, 1, SomeString)]
[InlineData(int.MaxValue - 1, 1, SomeString)]
[InlineData(int.MaxValue, 1, SomeString)]
// Effective Length: 1, Inner array length: 2
[InlineData(int.MinValue, 1, EmptyString, AnotherString)]
[InlineData(int.MinValue + 1, 1, EmptyString, AnotherString)]
[InlineData(MinusFifteen, 1, EmptyString, AnotherString)]
[InlineData(-1, 1, EmptyString, AnotherString)]
[InlineData(1, 1, EmptyString, AnotherString)]
[InlineData(5, 2, EmptyString, SomeString)]
[InlineData(PlusFifteen, 1, EmptyString, AnotherString)]
[InlineData(int.MaxValue - 1, 1, EmptyString, AnotherString)]
[InlineData(int.MaxValue, 1, EmptyString, AnotherString)]
// Effective Length: 2, Inner array length: 2
[InlineData(int.MinValue, 2, EmptyString, SomeString)]
[InlineData(int.MinValue + 1, 2, EmptyString, SomeString)]
[InlineData(MinusFifteen, 2, EmptyString, SomeString)]
[InlineData(-1, 2, EmptyString, SomeString)]
[InlineData(2, 2, EmptyString, SomeString)]
[InlineData(PlusFifteen, 2, EmptyString, SomeString)]
[InlineData(int.MaxValue - 1, 2, EmptyString, SomeString)]
[InlineData(int.MaxValue, 2, EmptyString, SomeString)]
// Effective Length: 3, Inner array length: 3
[InlineData(int.MinValue, 3, LowerSomeString, null, SomeString)]
[InlineData(int.MinValue + 1, 3, LowerSomeString, null, SomeString)]
[InlineData(MinusFifteen, 3, LowerSomeString, null, SomeString)]
[InlineData(-1, 3, LowerSomeString, null, SomeString)]
[InlineData(3, 3, LowerSomeString, null, SomeString)]
[InlineData(PlusFifteen, 3, LowerSomeString, null, SomeString)]
[InlineData(int.MaxValue - 1, 3, LowerSomeString, null, SomeString)]
[InlineData(int.MaxValue, 3, LowerSomeString, null, SomeString)]
public void Indexer_IndexIsOutOfRange_ExpectIndexOutOfRangeException(
int index, int sourceLength, params string?[] sourceItems)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ namespace PrimeFuncPack.Core.Tests;
partial class FlatArrayTest
{
[Theory]
[InlineData(Zero)]
[InlineData(One)]
[InlineData(0)]
[InlineData(1)]
[InlineData(PlusFifteen)]
[InlineData(int.MaxValue - 1)]
[InlineData(int.MaxValue)]
public void IndexerRef_IndexFromEnd_SourceIsDefault_ExpectIndexOutOfRangeException(int indexFromEnd)
{
var fromEnd = Index.FromEnd(indexFromEnd);
Expand Down Expand Up @@ -45,12 +47,26 @@ public void IndexerRef_IndexFromEnd_IndexIsInRange_ExpectItemIsFromSourceItemsBy
}

[Theory]
// Effective Length: 1, Inner array length: 1
[InlineData(0, 1, SomeString)]
[InlineData(2, 1, SomeString)]
[InlineData(int.MaxValue - 1, 1, SomeString)]
[InlineData(int.MaxValue, 1, SomeString)]
// Effective Length: 1, Inner array length: 2
[InlineData(0, 1, EmptyString, AnotherString)]
[InlineData(2, 1, EmptyString, AnotherString)]
[InlineData(int.MaxValue - 1, 1, EmptyString, AnotherString)]
[InlineData(int.MaxValue, 1, EmptyString, AnotherString)]
// Effective Length: 2, Inner array length: 2
[InlineData(0, 2, EmptyString, SomeString)]
[InlineData(3, 2, EmptyString, SomeString)]
[InlineData(int.MaxValue - 1, 2, EmptyString, SomeString)]
[InlineData(int.MaxValue, 2, EmptyString, SomeString)]
// Effective Length: 3, Inner array length: 3
[InlineData(0, 3, LowerSomeString, null, SomeString)]
[InlineData(4, 3, LowerSomeString, null, SomeString)]
[InlineData(int.MaxValue - 1, 3, LowerSomeString, null, SomeString)]
[InlineData(int.MaxValue, 3, LowerSomeString, null, SomeString)]
public void IndexerRef_IndexFromEnd_IndexIsOutOfRange_ExpectIndexOutOfRangeException(
int indexFromEnd, int sourceLength, params string?[] sourceItems)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ namespace PrimeFuncPack.Core.Tests;
partial class FlatArrayTest
{
[Theory]
[InlineData(Zero)]
[InlineData(One)]
[InlineData(0)]
[InlineData(1)]
[InlineData(PlusFifteen)]
[InlineData(int.MaxValue - 1)]
[InlineData(int.MaxValue)]
public void IndexerRef_IndexFromStart_SourceIsDefault_ExpectIndexOutOfRangeException(int index)
{
var fromStart = Index.FromStart(index);
Expand Down Expand Up @@ -48,9 +50,26 @@ public void IndexerRef_IndexFromStart_IndexIsInRange_ExpectItemIsFromSourceItems
}

[Theory]
// Effective Length: 1, Inner array length: 1
[InlineData(1, 1, SomeString)]
[InlineData(PlusFifteen, 1, SomeString)]
[InlineData(int.MaxValue - 1, 1, SomeString)]
[InlineData(int.MaxValue, 1, SomeString)]
// Effective Length: 1, Inner array length: 2
[InlineData(1, 1, EmptyString, AnotherString)]
[InlineData(5, 2, EmptyString, SomeString)]
[InlineData(PlusFifteen, 1, EmptyString, AnotherString)]
[InlineData(int.MaxValue - 1, 1, EmptyString, AnotherString)]
[InlineData(int.MaxValue, 1, EmptyString, AnotherString)]
// Effective Length: 2, Inner array length: 2
[InlineData(2, 2, EmptyString, SomeString)]
[InlineData(PlusFifteen, 2, EmptyString, SomeString)]
[InlineData(int.MaxValue - 1, 2, EmptyString, SomeString)]
[InlineData(int.MaxValue, 2, EmptyString, SomeString)]
// Effective Length: 3, Inner array length: 3
[InlineData(3, 3, LowerSomeString, null, SomeString)]
[InlineData(PlusFifteen, 3, LowerSomeString, null, SomeString)]
[InlineData(int.MaxValue - 1, 3, LowerSomeString, null, SomeString)]
[InlineData(int.MaxValue, 3, LowerSomeString, null, SomeString)]
public void IndexerRef_IndexFromStart_IndexIsOutOfRange_ExpectIndexOutOfRangeException(
int index, int sourceLength, params string?[] sourceItems)
{
Expand Down
Loading

0 comments on commit 29b68dd

Please sign in to comment.