summaryrefslogtreecommitdiff
path: root/stack_test.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-04-19 16:48:18 +0200
committerDimitri Sokolyuk <demon@dim13.org>2016-04-19 16:48:18 +0200
commitfe8f23a25989b3ae287975d08e7e5a47ec5ff1e8 (patch)
treeabb66c87fef65638bcaecbbbe31aa5c41e5511b8 /stack_test.go
parent6491f45cfd5671ffff53068444aa3a3f9dba94d6 (diff)
Test Peek
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++ {