MCPcopy
hub / github.com/expr-lang/expr / formatUnequalValues

Function formatUnequalValues

internal/testify/assert/assertions.go:554–564  ·  view source on GitHub ↗

formatUnequalValues takes two values of arbitrary types and returns string representations appropriate to be presented to the user. If the values are not of like type, the returned strings will be prefixed with the type name, and the value will be enclosed in parentheses similar to a type conversio

(expected, actual interface{})

Source from the content-addressed store, hash-verified

552// with the type name, and the value will be enclosed in parentheses similar
553// to a type conversion in the Go grammar.
554func formatUnequalValues(expected, actual interface{}) (e string, a string) {
555 if reflect.TypeOf(expected) != reflect.TypeOf(actual) {
556 return fmt.Sprintf("%T(%s)", expected, truncatingFormat(expected)),
557 fmt.Sprintf("%T(%s)", actual, truncatingFormat(actual))
558 }
559 switch expected.(type) {
560 case time.Duration:
561 return fmt.Sprintf("%v", expected), fmt.Sprintf("%v", actual)
562 }
563 return truncatingFormat(expected), truncatingFormat(actual)
564}
565
566// truncatingFormat formats the data and truncates it if it's too long.
567//

Callers 4

TestFormatUnequalValuesFunction · 0.85
EqualFunction · 0.85
EqualValuesFunction · 0.85
EqualExportedValuesFunction · 0.85

Calls 2

truncatingFormatFunction · 0.85
SprintfMethod · 0.80

Tested by 1

TestFormatUnequalValuesFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…