2
0
mirror of https://github.com/0xAX/go-algorithms synced 2024-11-13 13:10:30 +00:00
go-algorithms/collections/queue/queue_test.go

30 lines
443 B
Go
Raw Normal View History

2014-08-11 13:24:15 +00:00
package queue
import "testing"
func Test_Queue(t *testing.T) {
queue := New()
queue.Add(1)
queue.Add(2)
queue.Add(3)
if queue.Length() != 3 {
t.Error("[Error] queue length is wrong")
}
element := queue.Remove()
if element != 1 {
t.Error("[Error] remove is wrong")
}
if queue.Length() != 2 {
t.Error("[Error] queue length is wrong after pop")
}
if queue.Peek() != 2 {
t.Error("[Error] queue Peek is wrong")
}
}