summaryrefslogtreecommitdiff
path: root/stack_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'stack_test.go')
-rw-r--r--stack_test.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/stack_test.go b/stack_test.go
index 32637fa..4f3bfce 100644
--- a/stack_test.go
+++ b/stack_test.go
@@ -69,6 +69,22 @@ func TestInsert(t *testing.T) {
}
}
+func TestPeek(t *testing.T) {
+ s := New()
+ v := s.Peek()
+ if v != nil {
+ t.Error("Expected nil")
+ }
+ s.Push(1)
+ v = s.Peek()
+ if v != 1 {
+ t.Error("Expected 1")
+ }
+ if s.Depth() != 1 {
+ t.Error("Expected depth of 1")
+ }
+}
+
func BenchmarkPushPopSingle(b *testing.B) {
s := New()
for i := 0; i < b.N; i++ {