-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented ValueQueue<T>. Renamed some interface.
- Loading branch information
1 parent
2c3b482
commit ca4b9be
Showing
21 changed files
with
774 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace NullGC.Collections; | ||
|
||
public interface IHasUnmanagedResource | ||
{ | ||
bool IsAllocated { get; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using NullGC.TestCommons; | ||
using Xunit.Abstractions; | ||
|
||
namespace NullGC.Collections.Tests; | ||
|
||
public class ValueQueueTests :AssertMemoryAllFreedBase | ||
{ | ||
public ValueQueueTests(ITestOutputHelper logger) : base(logger, false) | ||
{ | ||
} | ||
|
||
[Fact] | ||
public void EmptyQueueFacts() | ||
{ | ||
var queue = new ValueQueue<int>(); | ||
Assert.False(queue.IsAllocated); | ||
Assert.Equal(0, queue.Count); | ||
Assert.Empty(queue); | ||
Assert.Throws<InvalidOperationException>(() => queue.Peek()); | ||
Assert.Throws<InvalidOperationException>(() => queue.Dequeue()); | ||
queue.Dispose(); | ||
Assert.True(AllocTracker.ClientIsAllFreed); | ||
queue.Dispose(); | ||
} | ||
|
||
[Fact] | ||
public void EnqueueDequeueFacts() | ||
{ | ||
var queue = new ValueQueue<int>(); | ||
queue.Enqueue(1); | ||
Assert.Equal(1, queue.Dequeue()); | ||
Assert.Equal(0, queue.Count); | ||
Assert.Empty(queue); | ||
Assert.Throws<InvalidOperationException>(() => queue.Dequeue()); | ||
queue.Enqueue(1); | ||
Assert.Single(queue); | ||
queue.Enqueue(2); | ||
queue.Enqueue(3); | ||
queue.Enqueue(4); | ||
queue.Enqueue(5); | ||
queue.Enqueue(6); | ||
Assert.Equal(6, queue.Count); | ||
Assert.Equal(6, queue.Count()); | ||
Assert.Equal(1, queue.Dequeue()); | ||
queue.Enqueue(7); | ||
Assert.Equal(2, queue.Dequeue()); | ||
Assert.Equal(3, queue.Dequeue()); | ||
Assert.Equal(4, queue.Dequeue()); | ||
Assert.Equal(5, queue.Dequeue()); | ||
Assert.Equal(6, queue.Dequeue()); | ||
Assert.Equal(7, queue.Dequeue()); | ||
|
||
queue.Dispose(); | ||
Assert.True(AllocTracker.ClientIsAllFreed); | ||
queue.Dispose(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.