Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Changes from all 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 @@ -26,10 +26,6 @@ public void ParameterlessConstructor()
Assert.Equal(0, builder.Count);
Assert.Equal(0, builder.Capacity);

// Indexing into the builder should throw
Assert.ThrowsAny<Exception>(() => builder[0]);
Assert.ThrowsAny<Exception>(() => builder[0] = default(T));

// Should use a cached array for capacity of 0
Assert.Same(Array.Empty<T>(), builder.ToArray());
}
Expand All @@ -45,14 +41,6 @@ public void CapacityConstructor(int capacity)
Assert.Equal(0, builder.Count);
Assert.Equal(capacity, builder.Capacity);

// Indexing into the builder should be unchecked in Release builds, so the
// jit can optimize better and have an easier time inlining the method.
// So we may not throw an exception for builder[i] if the Capacity > i.

// If we index @ Capacity and beyond, however, we should throw regardless of build config
Assert.ThrowsAny<Exception>(() => builder[capacity]);
Assert.ThrowsAny<Exception>(() => builder[capacity] = default(T));

// Should use a cached array for count of 0, regardless of capacity
Assert.Same(Array.Empty<T>(), builder.ToArray());
}
Expand All @@ -74,13 +62,6 @@ public void Count(int count)
{
T item = builder[i];
}

// Again, builder[count] may not throw for Release builds unless
// Count == Capacity, so don't assert that here.

// After Capacity, we should throw in Debug and Release builds.
Assert.ThrowsAny<Exception>(() => builder[builder.Capacity]);
Assert.ThrowsAny<Exception>(() => builder[builder.Capacity] = default(T));
}

[Theory]
Expand Down Expand Up @@ -137,10 +118,6 @@ public void UncheckedAdd(int capacity)
}

VerifyBuilderContents(Enumerable.Repeat(default(T), capacity), builder);

// Count == Capacity now, so attempting to add more should raise
// an assert or generate an IndexOutOfRangeException
Assert.ThrowsAny<Exception>(() => builder.UncheckedAdd(default(T)));
}

public static TheoryData<int> CapacityData()
Expand Down