MCPcopy
hub / github.com/google/go-cmp / coalesceAdjacentRecords

Function coalesceAdjacentRecords

cmp/report_compare.go:409–433  ·  view source on GitHub ↗

coalesceAdjacentRecords coalesces the list of records into groups of adjacent equal, or unequal counts.

(name string, recs []reportRecord)

Source from the content-addressed store, hash-verified

407// coalesceAdjacentRecords coalesces the list of records into groups of
408// adjacent equal, or unequal counts.
409func coalesceAdjacentRecords(name string, recs []reportRecord) (groups []diffStats) {
410 var prevCase int // Arbitrary index into which case last occurred
411 lastStats := func(i int) *diffStats {
412 if prevCase != i {
413 groups = append(groups, diffStats{Name: name})
414 prevCase = i
415 }
416 return &groups[len(groups)-1]
417 }
418 for _, r := range recs {
419 switch rv := r.Value; {
420 case rv.NumIgnored > 0 && rv.NumSame+rv.NumDiff == 0:
421 lastStats(1).NumIgnored++
422 case rv.NumDiff == 0:
423 lastStats(1).NumIdentical++
424 case rv.NumDiff > 0 && !rv.ValueY.IsValid():
425 lastStats(2).NumRemoved++
426 case rv.NumDiff > 0 && !rv.ValueX.IsValid():
427 lastStats(2).NumInserted++
428 default:
429 lastStats(2).NumModified++
430 }
431 }
432 return groups
433}

Callers 1

formatDiffListMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected