MCPcopy Create free account
hub / github.com/benbjohnson/immutable / validateForwardIterator

Method validateForwardIterator

immutable_test.go:363–378  ·  view source on GitHub ↗
(typ string, itr *ListIterator[int])

Source from the content-addressed store, hash-verified

361}
362
363func (l *TList) validateForwardIterator(typ string, itr *ListIterator[int]) error {
364 for i := range l.std {
365 if j, v := itr.Next(); i != j || l.std[i] != v {
366 return fmt.Errorf("ListIterator.Next()=<%v,%v>, expected <%v,%v> [%s]", j, v, i, l.std[i], typ)
367 }
368
369 done := i == len(l.std)-1
370 if v := itr.Done(); v != done {
371 return fmt.Errorf("ListIterator.Done()=%v, expected %v [%s]", v, done, typ)
372 }
373 }
374 if i, v := itr.Next(); i != -1 || v != 0 {
375 return fmt.Errorf("ListIterator.Next()=<%v,%v>, expected DONE [%s]", i, v, typ)
376 }
377 return nil
378}
379
380func (l *TList) validateBackwardIterator(typ string, itr *ListIterator[int]) error {
381 itr.Last()

Callers 1

ValidateMethod · 0.95

Calls 2

NextMethod · 0.45
DoneMethod · 0.45

Tested by

no test coverage detected