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) } }