MCPcopy Create free account
hub / github.com/stretchr/testify / formatUnequalValues

Function formatUnequalValues

assert/assertions.go:570–580  ·  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

568// with the type name, and the value will be enclosed in parentheses similar
569// to a type conversion in the Go grammar.
570func formatUnequalValues(expected, actual interface{}) (e string, a string) {
571 if reflect.TypeOf(expected) != reflect.TypeOf(actual) {
572 return fmt.Sprintf("%T(%s)", expected, truncatingFormat(expected)),
573 fmt.Sprintf("%T(%s)", actual, truncatingFormat(actual))
574 }
575 switch expected.(type) {
576 case time.Duration:
577 return fmt.Sprintf("%v", expected), fmt.Sprintf("%v", actual)
578 }
579 return truncatingFormat(expected), truncatingFormat(actual)
580}
581
582// truncatingFormat formats the data and truncates it if it's too long.
583//

Callers 4

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

Calls 1

truncatingFormatFunction · 0.85

Tested by 1

TestFormatUnequalValuesFunction · 0.68