mirror of
https://github.com/cubixle/playground.git
synced 2026-04-29 23:18:41 +01:00
sorted queue
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package queue_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
queue "github.com/cubixle/playground/sorted_queue"
|
||||
)
|
||||
|
||||
func TestQueue(t *testing.T) {
|
||||
q := queue.NewQueue()
|
||||
q.Put(&queue.Item{ID: "aaa", Priority: 6})
|
||||
q.Put(&queue.Item{ID: "bbb", Priority: 7})
|
||||
q.Put(&queue.Item{ID: "ccc", Priority: 2})
|
||||
q.Put(&queue.Item{ID: "ddd", Priority: 1})
|
||||
|
||||
v := q.GetNext()
|
||||
if v == nil {
|
||||
t.Fatal("didn't get a item")
|
||||
}
|
||||
if v.ID != "bbb" {
|
||||
t.Fatal("id wasn't what we expected")
|
||||
}
|
||||
if v.ID != "aaa" {
|
||||
t.Fatal("id wasn't what we expected")
|
||||
}
|
||||
if v.ID != "ccc" {
|
||||
t.Fatal("id wasn't what we expected")
|
||||
}
|
||||
if v.ID != "ddd" {
|
||||
t.Fatal("id wasn't what we expected")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user