(t *testing.T)
| 48 | } |
| 49 | |
| 50 | func TestQueueDequeue(t *testing.T) { |
| 51 | assert := func(actualValue interface{}, expectedValue interface{}) { |
| 52 | if actualValue != expectedValue { |
| 53 | t.Errorf("Got %v expected %v", actualValue, expectedValue) |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | queue := New(3) |
| 58 | assert(queue.Empty(), true) |
| 59 | assert(queue.Empty(), true) |
| 60 | assert(queue.Full(), false) |
| 61 | assert(queue.Size(), 0) |
| 62 | queue.Enqueue(1) |
| 63 | assert(queue.Size(), 1) |
| 64 | queue.Enqueue(2) |
| 65 | assert(queue.Size(), 2) |
| 66 | |
| 67 | queue.Enqueue(3) |
| 68 | assert(queue.Size(), 3) |
| 69 | assert(queue.Empty(), false) |
| 70 | assert(queue.Full(), true) |
| 71 | |
| 72 | queue.Dequeue() |
| 73 | assert(queue.Size(), 2) |
| 74 | |
| 75 | if actualValue, ok := queue.Peek(); actualValue != 2 || !ok { |
| 76 | t.Errorf("Got %v expected %v", actualValue, 2) |
| 77 | } |
| 78 | assert(queue.Size(), 2) |
| 79 | |
| 80 | if actualValue, ok := queue.Dequeue(); actualValue != 2 || !ok { |
| 81 | t.Errorf("Got %v expected %v", actualValue, 2) |
| 82 | } |
| 83 | assert(queue.Size(), 1) |
| 84 | |
| 85 | if actualValue, ok := queue.Dequeue(); actualValue != 3 || !ok { |
| 86 | t.Errorf("Got %v expected %v", actualValue, 3) |
| 87 | } |
| 88 | assert(queue.Size(), 0) |
| 89 | assert(queue.Empty(), true) |
| 90 | assert(queue.Full(), false) |
| 91 | |
| 92 | if actualValue, ok := queue.Dequeue(); actualValue != nil || ok { |
| 93 | t.Errorf("Got %v expected %v", actualValue, nil) |
| 94 | } |
| 95 | assert(queue.Size(), 0) |
| 96 | |
| 97 | assert(queue.Empty(), true) |
| 98 | assert(queue.Full(), false) |
| 99 | assert(len(queue.Values()), 0) |
| 100 | } |
| 101 | |
| 102 | func TestQueueDequeueFull(t *testing.T) { |
| 103 | assert := func(actualValue interface{}, expectedValue interface{}) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…