algorithms/fundamentals/queue/queue_test.go

36 lines
526 B
Go
Raw Normal View History

2021-11-08 21:53:15 +02:00
package queue
import (
"log"
"testing"
)
func TestSimple(t *testing.T) {
queue := NewQueue()
queue.Enqueue(10)
queue.Enqueue(20)
queue.Enqueue(30)
first, second := queue.Dequeue().(int), queue.Dequeue().(int)
if first != 10 && second != 20 {
log.Fatal("wrong order")
}
}
func TestSize(t *testing.T) {
queue := NewQueue()
if queue.Size() != 0 {
log.Fatal("empty queue should have size 0")
}
queue.Enqueue(10)
queue.Enqueue(20)
queue.Enqueue(30)
if queue.Size() != 3 {
log.Fatal("wrong size")
}
}