mirror of
https://github.com/emirpasic/gods.git
synced 2026-06-15 16:16:35 +03:00
- test iterator last on all structures with reversible iterators
This commit is contained in:
@@ -176,7 +176,7 @@ func TestStackIteratorPrev(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestListIteratorReset(t *testing.T) {
|
||||
func TestStackIteratorReset(t *testing.T) {
|
||||
stack := New()
|
||||
it := stack.Iterator()
|
||||
it.Reset()
|
||||
@@ -192,6 +192,23 @@ func TestListIteratorReset(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestStackIteratorLast(t *testing.T) {
|
||||
stack := New()
|
||||
it := stack.Iterator()
|
||||
if actualValue, expectedValue := it.Last(), false; actualValue != expectedValue {
|
||||
t.Errorf("Got %v expected %v", actualValue, expectedValue)
|
||||
}
|
||||
stack.Push("a")
|
||||
stack.Push("b")
|
||||
stack.Push("c")
|
||||
if actualValue, expectedValue := it.Last(), true; actualValue != expectedValue {
|
||||
t.Errorf("Got %v expected %v", actualValue, expectedValue)
|
||||
}
|
||||
if index, value := it.Index(), it.Value(); index != 2 || value != "a" {
|
||||
t.Errorf("Got %v,%v expected %v,%v", index, value, 2, "a")
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkStack(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
stack := New()
|
||||
|
||||
Reference in New Issue
Block a user