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

Method validateIterator

immutable_test.go:1379–1397  ·  view source on GitHub ↗
(itr *MapIterator[int, int])

Source from the content-addressed store, hash-verified

1377}
1378
1379func (m *TMap) validateIterator(itr *MapIterator[int, int]) error {
1380 other := make(map[int]int)
1381 for !itr.Done() {
1382 k, v, _ := itr.Next()
1383 other[k] = v
1384 }
1385 if len(other) != len(m.std) {
1386 return fmt.Errorf("map iterator size mismatch: %v!=%v", len(m.std), len(other))
1387 }
1388 for k, v := range m.std {
1389 if v != other[k] {
1390 return fmt.Errorf("map iterator mismatch: key=%v, %v!=%v", k, v, other[k])
1391 }
1392 }
1393 if k, v, ok := itr.Next(); ok {
1394 return fmt.Errorf("map iterator returned key/value after done: <%v/%v>", k, v)
1395 }
1396 return nil
1397}
1398
1399func BenchmarkBuiltinMap_Set(b *testing.B) {
1400 b.ReportAllocs()

Callers 1

ValidateMethod · 0.95

Calls 2

DoneMethod · 0.45
NextMethod · 0.45

Tested by

no test coverage detected