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

Method Validate

immutable_test.go:1358–1377  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1356}
1357
1358func (m *TMap) Validate() error {
1359 for _, k := range m.keys {
1360 if v, ok := m.im.Get(k); !ok {
1361 return fmt.Errorf("key not found: %d", k)
1362 } else if v != m.std[k] {
1363 return fmt.Errorf("key (%d) mismatch: immutable=%d, std=%d", k, v, m.std[k])
1364 }
1365 if v, ok := m.builder.Get(k); !ok {
1366 return fmt.Errorf("builder key not found: %d", k)
1367 } else if v != m.std[k] {
1368 return fmt.Errorf("builder key (%d) mismatch: immutable=%d, std=%d", k, v, m.std[k])
1369 }
1370 }
1371 if err := m.validateIterator(m.im.Iterator()); err != nil {
1372 return fmt.Errorf("basic: %s", err)
1373 } else if err := m.validateIterator(m.builder.Iterator()); err != nil {
1374 return fmt.Errorf("builder: %s", err)
1375 }
1376 return nil
1377}
1378
1379func (m *TMap) validateIterator(itr *MapIterator[int, int]) error {
1380 other := make(map[int]int)

Callers 2

TestMap_SetFunction · 0.45
TestMap_DeleteFunction · 0.45

Calls 3

validateIteratorMethod · 0.95
GetMethod · 0.45
IteratorMethod · 0.45

Tested by

no test coverage detected