summaryrefslogtreecommitdiff
path: root/stack_test.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-04-05 16:53:20 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-04-05 16:53:20 +0200
commitbdecd1b6e0ea6d9bf6c205d418ac989c0aa0deb1 (patch)
tree11878202a7b1db9688f82af7fef975a3be40b95b /stack_test.go
parentf3d0b3595a01cddbe7438d5cda0bc2aa68a187f8 (diff)
Add Insert method
Diffstat (limited to 'stack_test.go')
-rw-r--r--stack_test.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/stack_test.go b/stack_test.go
index e66a3ae..31e6ff7 100644
--- a/stack_test.go
+++ b/stack_test.go
@@ -52,6 +52,23 @@ func TestSwap(t *testing.T) {
}
}
+func TestInsert(t *testing.T) {
+ s := NewStack()
+ s.Push(1)
+ s.Insert(2)
+ if s.Depth() != 2 {
+ t.Error("Expected depth of 2")
+ }
+ a := s.Pop()
+ b := s.Pop()
+ if s.Depth() != 0 {
+ t.Error("Expected depth of 0")
+ }
+ if a != 1 || b != 2 {
+ t.Error("Expected swapped values")
+ }
+}
+
func BenchmarkPushPopSingle(b *testing.B) {
s := NewStack()
for i := 0; i < b.N; i++ {