- test iterator end on reverse-iterable data structures

- fix red-black tree
This commit is contained in:
Emir Pasic
2016-06-27 02:42:05 +02:00
parent f052c96069
commit 02f40db0cf
8 changed files with 249 additions and 32 deletions
+27
View File
@@ -192,6 +192,33 @@ func TestStackIteratorBegin(t *testing.T) {
}
}
func TestStackIteratorEnd(t *testing.T) {
stack := New()
it := stack.Iterator()
if index := it.Index(); index != -1 {
t.Errorf("Got %v expected %v", index, -1)
}
it.End()
if index := it.Index(); index != 0 {
t.Errorf("Got %v expected %v", index, 0)
}
stack.Push("a")
stack.Push("b")
stack.Push("c")
it.End()
if index := it.Index(); index != stack.Size() {
t.Errorf("Got %v expected %v", index, stack.Size())
}
it.Prev()
if index, value := it.Index(), it.Value(); index != stack.Size()-1 || value != "a" {
t.Errorf("Got %v,%v expected %v,%v", index, value, stack.Size()-1, "a")
}
}
func TestStackIteratorFirst(t *testing.T) {
stack := New()
it := stack.Iterator()