-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
longs should be enough for everybode.
- Loading branch information
Showing
3 changed files
with
55 additions
and
10 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
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,42 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Cone.Core | ||
{ | ||
[Describe(typeof(CircularQueue<>))] | ||
public class CircularQueueSpec | ||
{ | ||
public void TryEnqueue_fails_when_at_capacity() { | ||
var q = new CircularQueue<int>(1); | ||
Assume.That(() => q.TryEnqueue(0)); | ||
|
||
Check.That(() => !q.TryEnqueue(1)); | ||
} | ||
|
||
public void TryEnqueue_fails_if_write_catches_up_to_read() { | ||
var q = new CircularQueue<int>(2); | ||
int ignored; | ||
Assume.That(() => q.TryEnqueue(0)); | ||
Assume.That(() => q.TryDeque(out ignored)); | ||
|
||
Assume.That(() => q.TryEnqueue(0)); | ||
Assume.That(() => q.TryEnqueue(1)); | ||
Check.That(() => !q.TryEnqueue(2)); | ||
} | ||
|
||
public void is_first_in_first_out() { | ||
var q = new CircularQueue<int>(2); | ||
|
||
Assume.That(() => q.TryEnqueue(0)); | ||
Assume.That(() => q.TryEnqueue(1)); | ||
|
||
int value; | ||
Check.That( | ||
() => q.TryDeque(out value) && value == 0, | ||
() => q.TryDeque(out value) && value == 1 | ||
); | ||
} | ||
} | ||
} |