1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-11-09 15:59:06 +01:00
LeetCode/go/implement-queue-using-stacks_test.go
Matej Focko 47c6862e92
go: add «232. Implement Queue using Stacks»
Signed-off-by: Matej Focko <me@mfocko.xyz>
2024-01-29 12:36:17 +01:00

49 lines
709 B
Go

package implement_queue_using_stacks
import (
"testing"
)
func TestEmpty(t *testing.T) {
obj := Constructor()
if !obj.Empty() {
t.Error("Queue should be empty")
}
}
func TestBasic(t *testing.T) {
q := Constructor()
q.Push(1)
q.Push(2)
if q.Peek() != 1 {
t.Error("1 should be at the front of the queue")
}
if q.Pop() != 1 {
t.Error("1 should've been removed from the queue")
}
if q.Empty() {
t.Error("Queue shouldn't be empty")
}
q.Push(3)
if q.Pop() != 2 {
t.Error("Queue should've removed 2")
}
if q.Empty() {
t.Error("Queue shouldn't be empty")
}
if q.Pop() != 3 {
t.Error("Queue should've removed 3")
}
if !q.Empty() {
t.Error("Queue should be empty")
}
}