You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
506 B
Go
30 lines
506 B
Go
10 years ago
|
package queue
|
||
|
|
||
|
import "testing"
|
||
|
|
||
|
func Test_Queue(t *testing.T) {
|
||
10 years ago
|
queue := New()
|
||
10 years ago
|
|
||
10 years ago
|
queue.Add(1)
|
||
|
queue.Add(2)
|
||
|
queue.Add(3)
|
||
10 years ago
|
|
||
10 years ago
|
if queue.Length() != 3 {
|
||
|
t.Error("[Error] queue length is wrong")
|
||
|
}
|
||
10 years ago
|
|
||
|
element := queue.Remove()
|
||
|
|
||
10 years ago
|
if element != 1 {
|
||
|
t.Error("[Error] remove is wrong")
|
||
|
}
|
||
10 years ago
|
|
||
10 years ago
|
if queue.Length() != 2 {
|
||
|
t.Error("[Error] queue length is wrong after pop")
|
||
|
}
|
||
|
|
||
|
if queue.Peek() != 2 {
|
||
|
t.Error("[Error] queue Peek is wrong")
|
||
|
}
|
||
10 years ago
|
}
|