- test iterator first on all iterable data structures

This commit is contained in:
Emir Pasic
2016-06-26 23:58:23 +02:00
parent bdfeab4912
commit cbc23a5b79
9 changed files with 141 additions and 5 deletions
+17
View File
@@ -192,6 +192,23 @@ func TestStackIteratorReset(t *testing.T) {
}
}
func TestStackIteratorFirst(t *testing.T) {
stack := New()
it := stack.Iterator()
if actualValue, expectedValue := it.First(), false; actualValue != expectedValue {
t.Errorf("Got %v expected %v", actualValue, expectedValue)
}
stack.Push("a")
stack.Push("b")
stack.Push("c")
if actualValue, expectedValue := it.First(), true; actualValue != expectedValue {
t.Errorf("Got %v expected %v", actualValue, expectedValue)
}
if index, value := it.Index(), it.Value(); index != 0 || value != "c" {
t.Errorf("Got %v,%v expected %v,%v", index, value, 0, "c")
}
}
func TestStackIteratorLast(t *testing.T) {
stack := New()
it := stack.Iterator()