Source File
report_value.go
Belonging Package
github.com/google/go-cmp/cmp
package cmp
import
Records []reportRecord // If populated, implies Value is not populated
TransformerName string // If non-empty, implies Value is populated
}
type reportRecord struct {
Key reflect.Value // Invalid for slice element
Value *valueNode
}
func ( *valueNode) ( PathStep) ( *valueNode) {
, := .Values()
= &valueNode{parent: , Type: .Type(), ValueX: , ValueY: }
switch s := .(type) {
case StructField:
assert(.Value == nil)
.Records = append(.Records, reportRecord{Key: reflect.ValueOf(.Name()), Value: })
case SliceIndex:
assert(.Value == nil)
.Records = append(.Records, reportRecord{Value: })
case MapIndex:
assert(.Value == nil)
.Records = append(.Records, reportRecord{Key: .Key(), Value: })
case Indirect:
assert(.Value == nil && .Records == nil)
.Value =
case TypeAssertion:
assert(.Value == nil && .Records == nil)
.Value =
case Transform:
assert(.Value == nil && .Records == nil)
.Value =
.TransformerName = .Name()
.NumTransformed++
default:
assert( == nil) // Must be the root step
}
return
}
func ( *valueNode) ( Result) {
assert(.MaxDepth == 0) // May only be called on leaf nodes
if .ByIgnore() {
.NumIgnored++
} else {
if .Equal() {
.NumSame++
} else {
.NumDiff++
}
}
assert(.NumSame+.NumDiff+.NumIgnored == 1)
if .ByMethod() {
.NumCompared++
}
if .ByFunc() {
.NumCompared++
}
assert(.NumCompared <= 1)
}
func ( *valueNode) () ( *valueNode) {
if .parent == nil {
return nil
}
= .parent
.NumSame += .NumSame
.NumDiff += .NumDiff
.NumIgnored += .NumIgnored
.NumCompared += .NumCompared
.NumTransformed += .NumTransformed
.NumChildren += .NumChildren + 1
if .MaxDepth < .MaxDepth+1 {
.MaxDepth = .MaxDepth + 1
}
return
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |