MCPcopy
hub / github.com/stretchr/testify / formatUnequalValues

Function formatUnequalValues

assert/assertions.go:605–615  ·  assert/assertions.go::formatUnequalValues

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

603// with the type name, and the value will be enclosed in parentheses similar
604// to a type conversion in the Go grammar.
605func formatUnequalValues(expected, actual interface{}) (e string, a string) {
606 if reflect.TypeOf(expected) != reflect.TypeOf(actual) {
607 return fmt.Sprintf("%T(%s)", expected, truncatingFormat(expected)),
608 fmt.Sprintf("%T(%s)", actual, truncatingFormat(actual))
609 }
610 switch expected.(type) {
611 case time.Duration:
612 return fmt.Sprintf("%v", expected), fmt.Sprintf("%v", actual)
613 }
614 return truncatingFormat(expected), truncatingFormat(actual)
615}
616
617// truncatingFormat formats the data and truncates it if it's too long.
618//

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