Skip to content

Commit

Permalink
Rearrange lines for generating value
Browse files Browse the repository at this point in the history
  • Loading branch information
mchlp committed Oct 24, 2022
1 parent 599719b commit df194dd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions assert/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,7 @@ func formatUnequalValues(expected, actual interface{}) (e string, a string) {
// The `printValueOfBasicTypes` flag controls whether or not to print the underlying
// value of pointers of basic types in addition to the pointer address.
func truncatingFormat(data interface{}, printValueOfBasicTypes bool) string {
value := fmt.Sprintf("%#v", data)

var value string
if printValueOfBasicTypes && reflect.ValueOf(data).Kind() == reflect.Ptr {
v := reflect.ValueOf(data).Elem()
for _, t := range basicTypes {
Expand All @@ -483,6 +482,10 @@ func truncatingFormat(data interface{}, printValueOfBasicTypes bool) string {
break
}
}
}

if value == "" {
value = fmt.Sprintf("%#v", data)
}

max := bufio.MaxScanTokenSize - 100 // Give us some space the type info too if needed.
Expand Down

0 comments on commit df194dd

Please sign in to comment.