Add remaining AddRange overloads for HashSet
This commit is contained in:
1 parent
3dea509958
commit
aa48407bba
2 files changed
+494
No files matched your search
@@ -197,5 +197,97 @@ namespace Recyclable.CollectionsTests
|
||||
_ = set.Should().Contain(new[] { 1, 2, 3 });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddRangeShouldAddItemsFromSortedSet()
|
||||
{
|
||||
using var source = new RecyclableSortedSet<int>();
|
||||
source.Add(1);
|
||||
source.Add(2);
|
||||
source.Add(3);
|
||||
using var set = new RecyclableHashSet<int>();
|
||||
|
||||
set.AddRange(source);
|
||||
|
||||
_ = set.Count.Should().Be(3);
|
||||
_ = set.Should().Contain(new[] { 1, 2, 3 });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddRangeShouldAddItemsFromLinkedList()
|
||||
{
|
||||
using var source = new RecyclableLinkedList<int>(new[] { 1, 2, 3 });
|
||||
using var set = new RecyclableHashSet<int>();
|
||||
|
||||
set.AddRange(source);
|
||||
|
||||
_ = set.Count.Should().Be(3);
|
||||
_ = set.Should().Contain(new[] { 1, 2, 3 });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddRangeShouldAddItemsFromPriorityQueue()
|
||||
{
|
||||
using var source = new RecyclablePriorityQueue<int>();
|
||||
source.Enqueue(1);
|
||||
source.Enqueue(2);
|
||||
source.Enqueue(3);
|
||||
using var set = new RecyclableHashSet<int>();
|
||||
|
||||
set.AddRange(source);
|
||||
|
||||
_ = set.Count.Should().Be(3);
|
||||
_ = set.Should().Contain(new[] { 1, 2, 3 });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddRangeShouldAddItemsFromDictionary()
|
||||
{
|
||||
using var source = new RecyclableDictionary<int, string>();
|
||||
source.Add(1, "a");
|
||||
source.Add(2, "b");
|
||||
using var set = new RecyclableHashSet<KeyValuePair<int, string>>();
|
||||
|
||||
set.AddRange(source);
|
||||
|
||||
_ = set.Count.Should().Be(2);
|
||||
set.Should().Contain(new[]
|
||||
{
|
||||
new KeyValuePair<int, string>(1, "a"),
|
||||
new KeyValuePair<int, string>(2, "b")
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddRangeShouldAddItemsFromSortedDictionary()
|
||||
{
|
||||
using var source = new RecyclableSortedDictionary<int, string>();
|
||||
source.Add(1, "a");
|
||||
source.Add(2, "b");
|
||||
using var set = new RecyclableHashSet<KeyValuePair<int, string>>();
|
||||
|
||||
set.AddRange(source);
|
||||
|
||||
_ = set.Count.Should().Be(2);
|
||||
set.Should().Contain(new[]
|
||||
{
|
||||
new KeyValuePair<int, string>(1, "a"),
|
||||
new KeyValuePair<int, string>(2, "b")
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddRangeShouldAddItemsFromSortedList()
|
||||
{
|
||||
using var source = new RecyclableSortedList<int, string>();
|
||||
source.Add(1, "a");
|
||||
source.Add(2, "b");
|
||||
using var set = new RecyclableHashSet<(int Key, string Value)>();
|
||||
|
||||
set.AddRange(source);
|
||||
|
||||
_ = set.Count.Should().Be(2);
|
||||
set.Should().Contain(new[] { (1, "a"), (2, "b") });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user