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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,11 @@ public void PushRange(T[] items)
{
throw new ArgumentNullException(nameof(items));
}

// No op if the length is zero
if (items.Length == 0)
return;

PushRange(items, 0, items.Length);
}

Expand Down Expand Up @@ -349,7 +354,6 @@ public void PushRange(T[] items, int startIndex, int count)
if (count == 0)
return;


Node head, tail;
head = tail = new Node(items[startIndex]);
for (int i = startIndex + 1; i < startIndex + count; i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ public void PushRange_NoItems_NothingAdded()
Assert.True(s.IsEmpty);
}

[Fact]
public void PushRange_NoItems_NothingAdded_NoRangeSpecified()
{
var s = new ConcurrentStack<int>();
Assert.True(s.IsEmpty);

s.PushRange(new int[0]);
Assert.True(s.IsEmpty);
}

[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
[InlineData(8, 10)]
[InlineData(16, 100)]
Expand Down Expand Up @@ -131,6 +141,8 @@ public void PushRange_InvalidArguments_Throws()
var stack = new ConcurrentStack<int>();
Assert.Throws<ArgumentNullException>(() => stack.PushRange(null));
Assert.Throws<ArgumentNullException>(() => stack.PushRange(null, 0, 0));
Assert.Throws<ArgumentOutOfRangeException>(() => stack.PushRange(new int[0], 0, 0));
Assert.Throws<ArgumentOutOfRangeException>(() => stack.PushRange(new int[0], 0, 1));
Assert.Throws<ArgumentOutOfRangeException>(() => stack.PushRange(new int[1], 0, -1));
Assert.Throws<ArgumentOutOfRangeException>(() => stack.PushRange(new int[1], -1, 1));
Assert.Throws<ArgumentOutOfRangeException>(() => stack.PushRange(new int[1], 2, 1));
Expand Down