@@ -24,7 +24,7 @@ import (
2424)
2525
2626func TestPriorityPut (t * testing.T ) {
27- q := NewPriorityQueue (1 )
27+ q := NewPriorityQueue (1 , false )
2828
2929 q .Put (mockItem (2 ))
3030
@@ -41,7 +41,7 @@ func TestPriorityPut(t *testing.T) {
4141}
4242
4343func TestPriorityGet (t * testing.T ) {
44- q := NewPriorityQueue (1 )
44+ q := NewPriorityQueue (1 , false )
4545
4646 q .Put (mockItem (2 ))
4747 result , err := q .Get (2 )
@@ -84,15 +84,15 @@ func TestPriorityGet(t *testing.T) {
8484}
8585
8686func TestAddEmptyPriorityPut (t * testing.T ) {
87- q := NewPriorityQueue (1 )
87+ q := NewPriorityQueue (1 , false )
8888
8989 q .Put ()
9090
9191 assert .Len (t , q .items , 0 )
9292}
9393
9494func TestPriorityGetNonPositiveNumber (t * testing.T ) {
95- q := NewPriorityQueue (1 )
95+ q := NewPriorityQueue (1 , false )
9696
9797 q .Put (mockItem (1 ))
9898
@@ -112,7 +112,7 @@ func TestPriorityGetNonPositiveNumber(t *testing.T) {
112112}
113113
114114func TestPriorityEmpty (t * testing.T ) {
115- q := NewPriorityQueue (1 )
115+ q := NewPriorityQueue (1 , false )
116116 assert .True (t , q .Empty ())
117117
118118 q .Put (mockItem (1 ))
@@ -121,7 +121,7 @@ func TestPriorityEmpty(t *testing.T) {
121121}
122122
123123func TestPriorityGetEmpty (t * testing.T ) {
124- q := NewPriorityQueue (1 )
124+ q := NewPriorityQueue (1 , false )
125125
126126 go func () {
127127 q .Put (mockItem (1 ))
@@ -139,7 +139,7 @@ func TestPriorityGetEmpty(t *testing.T) {
139139}
140140
141141func TestMultiplePriorityGetEmpty (t * testing.T ) {
142- q := NewPriorityQueue (1 )
142+ q := NewPriorityQueue (1 , false )
143143 var wg sync.WaitGroup
144144 wg .Add (2 )
145145 results := make ([][]Item , 2 )
@@ -175,7 +175,7 @@ func TestMultiplePriorityGetEmpty(t *testing.T) {
175175}
176176
177177func TestEmptyPriorityGetWithDispose (t * testing.T ) {
178- q := NewPriorityQueue (1 )
178+ q := NewPriorityQueue (1 , false )
179179 var wg sync.WaitGroup
180180 wg .Add (1 )
181181
@@ -197,7 +197,7 @@ func TestEmptyPriorityGetWithDispose(t *testing.T) {
197197}
198198
199199func TestPriorityGetPutDisposed (t * testing.T ) {
200- q := NewPriorityQueue (1 )
200+ q := NewPriorityQueue (1 , false )
201201 q .Dispose ()
202202
203203 _ , err := q .Get (1 )
@@ -208,7 +208,7 @@ func TestPriorityGetPutDisposed(t *testing.T) {
208208}
209209
210210func BenchmarkPriorityQueue (b * testing.B ) {
211- q := NewPriorityQueue (b .N )
211+ q := NewPriorityQueue (b .N , false )
212212 var wg sync.WaitGroup
213213 wg .Add (1 )
214214 i := 0
@@ -232,16 +232,24 @@ func BenchmarkPriorityQueue(b *testing.B) {
232232}
233233
234234func TestPriorityPeek (t * testing.T ) {
235- q := NewPriorityQueue (1 )
235+ q := NewPriorityQueue (1 , false )
236236 q .Put (mockItem (1 ))
237237
238238 assert .Equal (t , mockItem (1 ), q .Peek ())
239239}
240240
241241func TestInsertDuplicate (t * testing.T ) {
242- q := NewPriorityQueue (1 )
242+ q := NewPriorityQueue (1 , false )
243243 q .Put (mockItem (1 ))
244244 q .Put (mockItem (1 ))
245245
246246 assert .Equal (t , 1 , q .Len ())
247247}
248+
249+ func TestAllowDuplicates (t * testing.T ) {
250+ q := NewPriorityQueue (2 , true )
251+ q .Put (mockItem (1 ))
252+ q .Put (mockItem (1 ))
253+
254+ assert .Equal (t , 2 , q .Len ())
255+ }
0 commit comments