Skip to content

Commit 26c44ac

Browse files
committed
added SliceSkipZero test to verify nothing is skipped if startIndex is 0
1 parent cdffbd8 commit 26c44ac

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

Cql/CoreTests/PrimitiveTests.cs

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3732,7 +3732,7 @@ public void Subtract_Decimal_To_MinDecimal()
37323732
*/
37333733

37343734
[TestMethod]
3735-
public void Slice_Skip2()
3735+
public void SliceSkip2()
37363736
{
37373737
//The Skip operator returns the elements in the list, skipping the first number elements.
37383738
//define "Skip2": Skip({ 1, 2, 3, 4, 5 }, 2) // { 3, 4, 5 }
@@ -3745,7 +3745,7 @@ public void Slice_Skip2()
37453745
}
37463746

37473747
[TestMethod]
3748-
public void Slice_SkipNull()
3748+
public void SliceSkipNull()
37493749
{
37503750
//If the number of elements is null, the result is the entire list, no elements are skipped.
37513751
//define "SkipNull": Skip({ 1, 3, 5 }, null) // { 1, 3, 5 }
@@ -3758,7 +3758,7 @@ public void Slice_SkipNull()
37583758
}
37593759

37603760
[TestMethod]
3761-
public void Slice_SkipEmpty()
3761+
public void SliceSkipEmpty()
37623762
{
37633763
//If the number of elements is less than zero, the result is an empty list.
37643764
//define "SkipEmpty": Skip({ 1, 3, 5 }, -1) // { }
@@ -3771,7 +3771,7 @@ public void Slice_SkipEmpty()
37713771
}
37723772

37733773
[TestMethod]
3774-
public void Slice_SkipIsNull()
3774+
public void SliceSkipIsNull()
37753775
{
37763776
//If the source list is null, the result is null.
37773777
//define "SkipIsNull": Skip(null, 2)
@@ -3782,9 +3782,20 @@ public void Slice_SkipIsNull()
37823782
Assert.IsNull(slicedList);
37833783
Assert.AreEqual(expectedList, slicedList);
37843784
}
3785-
3785+
3786+
[TestMethod]
3787+
public void SliceSkipZero()
3788+
{
3789+
var rtx = GetNewContext();
3790+
var inputList = new List<int> { 1, 2, 3, 4, 5 };
3791+
var expectedList = new List<int> { 1, 2, 3, 4, 5 };
3792+
var slicedList = rtx.Operators.Slice(inputList, 0, null);
3793+
Assert.IsNotNull(slicedList);
3794+
CollectionAssert.AreEqual(expectedList, slicedList.ToList());
3795+
}
3796+
37863797
[TestMethod]
3787-
public void Slice_Tail234()
3798+
public void SliceTail234()
37883799
{
37893800
//The Tail operator returns all but the first element from the given list.
37903801
//define "Tail234": Tail({ 1, 2, 3, 4 }) // { 2, 3, 4 }
@@ -3797,7 +3808,7 @@ public void Slice_Tail234()
37973808
}
37983809

37993810
[TestMethod]
3800-
public void Slice_TailEmpty()
3811+
public void SliceTailEmpty()
38013812
{
38023813
//If the list is empty, the result is empty.
38033814
//define "TailEmpty": Tail({ }) // { }
@@ -3810,7 +3821,7 @@ public void Slice_TailEmpty()
38103821
}
38113822

38123823
[TestMethod]
3813-
public void Slice_TailIsNull()
3824+
public void SliceTailIsNull()
38143825
{
38153826
//If the source list is null, the result is null.
38163827
//define "TailIsNull": Tail(null)
@@ -3823,7 +3834,7 @@ public void Slice_TailIsNull()
38233834
}
38243835

38253836
[TestMethod]
3826-
public void Slice_Take2()
3837+
public void SliceTake2()
38273838
{
38283839
//The Take operator returns the first number elements from the given list.
38293840
//define "Take2": Take({ 1, 2, 3, 4 }, 2) // { 1, 2 }
@@ -3836,7 +3847,7 @@ public void Slice_Take2()
38363847
}
38373848

38383849
[TestMethod]
3839-
public void Slice_TakeTooMany()
3850+
public void SliceTakeTooMany()
38403851
{
38413852
//If the list has less than number elements, the result only contains the elements in the list.
38423853
//define "TakeTooMany": Take({ 1, 2 }, 3) // { 1, 2 }
@@ -3849,7 +3860,7 @@ public void Slice_TakeTooMany()
38493860
}
38503861

38513862
[TestMethod]
3852-
public void Slice_TakeEmpty()
3863+
public void SliceTakeEmpty()
38533864
{
38543865
//If number is null, or 0 or less, the result is an empty list.
38553866
//define "TakeEmpty": Take({ 1, 2, 3, 4 }, null) // { }
@@ -3862,7 +3873,7 @@ public void Slice_TakeEmpty()
38623873
}
38633874

38643875
[TestMethod]
3865-
public void Slice_TakeIsNull()
3876+
public void SliceTakeIsNull()
38663877
{
38673878
//If the source list is null, the result is null.
38683879
//define "TakeIsNull": Take(null, 2)

0 commit comments

Comments
 (0)