summaryrefslogtreecommitdiff
path: root/stack_test.go
diff options
context:
space:
mode:
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++ {