You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

20 lines
381 B

package iterator
import (
"fmt"
"testing"
)
func TestArrayIterator_HashNext(t *testing.T) {
arr := []interface{}{1, 3, 6, 9, 2, 4, 6}
a := 0
iterator := ArrayIterator{array: arr, index: &a}
for it := iterator; iterator.HashNext(); iterator.Next() {
k, v := it.Index(), it.Value().(int)
for v != arr[*k] {
fmt.Errorf("发生错误!")
}
fmt.Println(*k, v)
}
}