- test iterator reset on all structures

This commit is contained in:
Emir Pasic
2016-06-26 21:44:23 +02:00
parent b86d413e66
commit 3a938233a0
10 changed files with 137 additions and 0 deletions
+16
View File
@@ -176,6 +176,22 @@ func TestStackIteratorPrev(t *testing.T) {
}
}
func TestListIteratorReset(t *testing.T) {
stack := New()
it := stack.Iterator()
it.Reset()
stack.Push("a")
stack.Push("b")
stack.Push("c")
for it.Next() {
}
it.Reset()
it.Next()
if index, value := it.Index(), it.Value(); index != 0 || value != "c" {
t.Errorf("Got %v,%v expected %v,%v", index, value, 0, "c")
}
}
func BenchmarkStack(b *testing.B) {
for i := 0; i < b.N; i++ {
stack := New()