diff options
author | Joe Tsai <joetsai@digital-static.net> | 2020-06-12 15:29:35 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-12 15:29:35 -0700 |
commit | 44914b370698a5a9ce868549d62d79473faebacc (patch) | |
tree | 04b9b2f2bc3a703c4515b20f64ffa10880358c1b /cmp/report_text.go | |
parent | f1780cfdde930250f45fbe0bb6e107be5b4e9514 (diff) | |
download | go-cmp-44914b370698a5a9ce868549d62d79473faebacc.tar.gz |
Disambiguate reporter output (#216)
The reporter tries to aggresively elide data that is not interesting
to the user. However, doing so many result in an output that does not
visually indicate the difference between semantically different objects.
This CL modifies the reporter to try increasingly verbose presets until
two different objects are formatted differently.
This CL includes a custom implementation of reflect.Type.String that
can print the type with fully qualified names to disambiguate types
that happen to have the same base package name.
Fixes #194
Diffstat (limited to 'cmp/report_text.go')
-rw-r--r-- | cmp/report_text.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/cmp/report_text.go b/cmp/report_text.go index 17a376e..b8ec9d2 100644 --- a/cmp/report_text.go +++ b/cmp/report_text.go @@ -10,6 +10,7 @@ import ( "math/rand" "strings" "time" + "unicode/utf8" "github.com/google/go-cmp/cmp/internal/flags" ) @@ -239,14 +240,14 @@ func (s textList) formatExpandedTo(b []byte, d diffMode, n indentMode) []byte { _, isLine := r.Value.(textLine) return r.Key == "" || !isLine }, - func(r textRecord) int { return len(r.Key) }, + func(r textRecord) int { return utf8.RuneCountInString(r.Key) }, ) alignValueLens := s.alignLens( func(r textRecord) bool { _, isLine := r.Value.(textLine) return !isLine || r.Value.Equal(textEllipsis) || r.Comment == nil }, - func(r textRecord) int { return len(r.Value.(textLine)) }, + func(r textRecord) int { return utf8.RuneCount(r.Value.(textLine)) }, ) // Format lists of simple lists in a batched form. |