From 99512ee1bb672d6bb6cc79802443ed68acd3f954 Mon Sep 17 00:00:00 2001 From: Francesco Banconi Date: Sun, 13 Nov 2022 17:01:42 +0000 Subject: [PATCH] Better message for suppressed output --- checker_test.go | 10 +++++----- report.go | 6 ++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/checker_test.go b/checker_test.go index 500baa7..d60995a 100644 --- a/checker_test.go +++ b/checker_test.go @@ -436,7 +436,7 @@ want: }, { about: "CmpEquals: different values, long output", checker: qt.CmpEquals(), - got: []interface{}{cmpEqualsWant, "extra line 1", "extra line 2"}, + got: []interface{}{cmpEqualsWant, "extra line 1", "extra line 2", "extra line 3"}, args: []interface{}{[]interface{}{cmpEqualsWant, "extra line 1"}}, expectedCheckFailure: fmt.Sprintf(` error: @@ -444,7 +444,7 @@ error: diff (-got +want): %s got: - + want: []interface {}{ struct { Strings []interface {}; Ints []int }{ @@ -456,7 +456,7 @@ want: }, "extra line 1", } -`, diff([]interface{}{cmpEqualsWant, "extra line 1", "extra line 2"}, []interface{}{cmpEqualsWant, "extra line 1"})), +`, diff([]interface{}{cmpEqualsWant, "extra line 1", "extra line 2", "extra line 3"}, []interface{}{cmpEqualsWant, "extra line 1"})), }, { about: "CmpEquals: different values: long output and verbose", checker: qt.CmpEquals(), @@ -677,9 +677,9 @@ error: diff (-got +want): %s got: - + want: - + `, diff([]interface{}{cmpEqualsWant, cmpEqualsWant}, []interface{}{cmpEqualsWant, cmpEqualsWant, 42})), }, { about: "DeepEquals: different values: long output and verbose", diff --git a/report.go b/report.go index a779a48..7383e6d 100644 --- a/report.go +++ b/report.go @@ -73,8 +73,10 @@ func writeError(w io.Writer, err error, p reportParams) { v = string(u) } else if s, ok := value.(SuppressedIfLong); ok { v = p.format(s.Value) - if !testingVerbose() && strings.Count(v, "\n") >= longValueLines { - v = "" + if !testingVerbose() { + if n := strings.Count(v, "\n"); n > longValueLines { + v = fmt.Sprintf("", n) + } } } else { v = p.format(value)