Skip to content

Commit

Permalink
Add a Stack.TrimExcess test
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentoub committed Feb 23, 2023
1 parent 456496a commit 678e131
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,17 @@ public void Stack_Generic_TrimExcess_AfterClearingAndAddingAllElementsBack(int c
}
}

[Fact]
public void Stack_Generic_TrimExcess_DoesNotInvalidateEnumeration()
{
Stack<T> stack = GenericStackFactory(10);
stack.EnsureCapacity(100);

IEnumerator<T> enumerator = stack.GetEnumerator();
stack.TrimExcess();
enumerator.MoveNext();
}

#endregion

[Theory]
Expand Down

0 comments on commit 678e131

Please sign in to comment.