@@ -116,61 +116,61 @@ func TestEqual(t *testing.T) {
116116 }{
117117 "integer" : {
118118 got : 42 , want : 84 ,
119- msg : "want 84, got 42" ,
119+ msg : "got: 42; want: 84 " ,
120120 },
121121 "int32 vs int64" : {
122122 got : int32 (42 ), want : int64 (42 ),
123- msg : "want 42, got 42" ,
123+ msg : "got: 42; want: 42" ,
124124 },
125125 "int vs string" : {
126126 got : 42 , want : "42" ,
127- msg : `want "42", got 42 ` ,
127+ msg : `got: 42; want: "42" ` ,
128128 },
129129 "string" : {
130130 got : "hello" , want : "world" ,
131- msg : `want "world", got "hello "` ,
131+ msg : `got: "hello"; want: "world "` ,
132132 },
133133 "bool" : {
134134 got : true , want : false ,
135- msg : "want false, got true" ,
135+ msg : "got: true; want: false " ,
136136 },
137137 "struct" : {
138138 got : intType {42 }, want : intType {84 },
139- msg : "want be_test.intType{val:84}, got be_test.intType{val:42 }" ,
139+ msg : "got: be_test.intType{val:42}; want: be_test.intType{val:84 }" ,
140140 },
141141 "pointer" : {
142142 got : & val1 , want : & val2 ,
143143 },
144144 "byte slice" : {
145145 got : []byte ("abc" ), want : []byte ("abd" ),
146- msg : `want []byte{0x61, 0x62, 0x64}, got []byte{0x61, 0x62, 0x63 }` ,
146+ msg : `got: []byte{0x61, 0x62, 0x63}; want: []byte{0x61, 0x62, 0x64 }` ,
147147 },
148148 "int slice" : {
149149 got : []int {42 , 84 }, want : []int {84 , 42 },
150- msg : `want []int{84, 42}, got []int{42, 84 }` ,
150+ msg : `got: []int{42, 84}; want: []int{84, 42 }` ,
151151 },
152152 "int slice vs any slice" : {
153153 got : []int {42 , 84 }, want : []any {42 , 84 },
154- msg : `want []interface {}{ 42, 84}, got []int {42, 84}` ,
154+ msg : `got: []int{ 42, 84}; want: []interface {} {42, 84}` ,
155155 },
156156 "time.Time" : {
157157 got : now , want : now .Add (time .Second ),
158158 },
159159 "nil vs non-nil" : {
160160 got : nil , want : 42 ,
161- msg : "want 42, got <nil>" ,
161+ msg : "got: <nil>; want: 42 " ,
162162 },
163163 "non-nil vs nil" : {
164164 got : 42 , want : nil ,
165- msg : "want <nil>, got 42 " ,
165+ msg : "got: 42; want: <nil>" ,
166166 },
167167 "nil vs empty" : {
168168 got : []int (nil ), want : []int {},
169- msg : "want []int{}, got []int(nil) " ,
169+ msg : "got: []int(nil); want: []int{} " ,
170170 },
171171 "map" : {
172172 got : map [string ]int {"a" : 42 }, want : map [string ]int {"a" : 84 },
173- msg : `want map[string]int{"a":84}, got map[string]int{"a":42 }` ,
173+ msg : `got: map[string]int{"a":42}; want: map[string]int{"a":84 }` ,
174174 },
175175 "chan" : {
176176 got : make (chan int ), want : make (chan int ),
@@ -188,7 +188,7 @@ func TestEqual(t *testing.T) {
188188 t .Error ("should not be fatal" )
189189 }
190190 if tc .msg != "" && tb .msg != tc .msg {
191- t .Errorf ("expected '%s', got '%s' " , tc .msg , tb .msg )
191+ t .Errorf ("got: %q; want: %q " , tb .msg , tc .msg )
192192 }
193193 })
194194 }
@@ -235,7 +235,7 @@ func TestEqual(t *testing.T) {
235235 }
236236 wantMsg := "no wants given"
237237 if tb .msg != wantMsg {
238- t .Errorf ("expected '%s', got '%s' " , wantMsg , tb .msg )
238+ t .Errorf ("got: %q; want: %q " , tb .msg , wantMsg )
239239 }
240240 })
241241 t .Run ("multiple wants" , func (t * testing.T ) {
@@ -265,9 +265,9 @@ func TestEqual(t *testing.T) {
265265 if tb .fatal {
266266 t .Error ("should not be fatal" )
267267 }
268- wantMsg := "want any of the [11 12 13], got 42 "
268+ wantMsg := "got: 42; want any of: [11 12 13]"
269269 if tb .msg != wantMsg {
270- t .Errorf ("expected '%s', got '%s' " , wantMsg , tb .msg )
270+ t .Errorf ("got: %q; want: %q " , tb .msg , wantMsg )
271271 }
272272 })
273273 })
@@ -294,7 +294,7 @@ func TestErr(t *testing.T) {
294294 }
295295 wantMsg := "unexpected error: oops"
296296 if tb .msg != wantMsg {
297- t .Errorf ("expected '%s', got '%s' " , wantMsg , tb .msg )
297+ t .Errorf ("got: %q; want: %q " , tb .msg , wantMsg )
298298 }
299299 })
300300 })
@@ -309,9 +309,9 @@ func TestErr(t *testing.T) {
309309 if tb .fatal {
310310 t .Error ("should not be fatal" )
311311 }
312- wantMsg := `want error, got <nil>`
312+ wantMsg := `got: <nil>; want: error `
313313 if tb .msg != wantMsg {
314- t .Errorf ("expected '%s', got '%s' " , wantMsg , tb .msg )
314+ t .Errorf ("got: %q; want: %q " , tb .msg , wantMsg )
315315 }
316316 })
317317 t .Run ("same error" , func (t * testing.T ) {
@@ -342,9 +342,9 @@ func TestErr(t *testing.T) {
342342 if tb .fatal {
343343 t .Error ("should not be fatal" )
344344 }
345- wantMsg := "want *errors.errorString(error 2), got *errors.errorString(error 1 )"
345+ wantMsg := "got: *errors.errorString(error 1); want: *errors.errorString(error 2 )"
346346 if tb .msg != wantMsg {
347- t .Errorf ("expected '%s', got '%s' " , wantMsg , tb .msg )
347+ t .Errorf ("got: %q; want: %q " , tb .msg , wantMsg )
348348 }
349349 })
350350 t .Run ("different type" , func (t * testing.T ) {
@@ -358,9 +358,9 @@ func TestErr(t *testing.T) {
358358 if tb .fatal {
359359 t .Error ("should not be fatal" )
360360 }
361- wantMsg := "want be_test.errType (oops), got *errors.errorString (oops)"
361+ wantMsg := "got: *errors.errorString (oops); want: be_test.errType (oops)"
362362 if tb .msg != wantMsg {
363- t .Errorf ("expected '%s', got '%s' " , wantMsg , tb .msg )
363+ t .Errorf ("got: %q; want: %q " , tb .msg , wantMsg )
364364 }
365365 })
366366 })
@@ -383,9 +383,9 @@ func TestErr(t *testing.T) {
383383 if tb .fatal {
384384 t .Error ("should not be fatal" )
385385 }
386- wantMsg := `want "day", got "the night is dark"`
386+ wantMsg := `got: "the night is dark"; want: "day "`
387387 if tb .msg != wantMsg {
388- t .Errorf ("expected '%s', got '%s' " , wantMsg , tb .msg )
388+ t .Errorf ("got: %q; want: %q " , tb .msg , wantMsg )
389389 }
390390 })
391391 })
@@ -408,9 +408,9 @@ func TestErr(t *testing.T) {
408408 if tb .fatal {
409409 t .Error ("should not be fatal" )
410410 }
411- wantMsg := "want *fs.PathError, got be_test.errType "
411+ wantMsg := "got: be_test.errType; want: *fs.PathError"
412412 if tb .msg != wantMsg {
413- t .Errorf ("expected '%s', got '%s' " , wantMsg , tb .msg )
413+ t .Errorf ("got: %q; want: %q " , tb .msg , wantMsg )
414414 }
415415 })
416416 })
@@ -426,7 +426,7 @@ func TestErr(t *testing.T) {
426426 }
427427 wantMsg := "unsupported want type: int"
428428 if tb .msg != wantMsg {
429- t .Errorf ("expected '%s', got '%s' " , wantMsg , tb .msg )
429+ t .Errorf ("got: %q; want: %q " , tb .msg , wantMsg )
430430 }
431431 })
432432 t .Run ("no wants" , func (t * testing.T ) {
@@ -449,9 +449,9 @@ func TestErr(t *testing.T) {
449449 if tb .fatal {
450450 t .Error ("should not be fatal" )
451451 }
452- wantMsg := "want error, got <nil>"
452+ wantMsg := "got: <nil>; want: error "
453453 if tb .msg != wantMsg {
454- t .Errorf ("expected '%s', got '%s' " , wantMsg , tb .msg )
454+ t .Errorf ("got: %q; want: %q " , tb .msg , wantMsg )
455455 }
456456 })
457457 })
@@ -482,9 +482,9 @@ func TestErr(t *testing.T) {
482482 if tb .fatal {
483483 t .Error ("should not be fatal" )
484484 }
485- wantMsg := "want any of the [failed 42 *fs.PathError], got be_test.errType(oops) "
485+ wantMsg := "got: be_test.errType(oops); want any of: [failed 42 *fs.PathError]"
486486 if tb .msg != wantMsg {
487- t .Errorf ("expected '%s', got '%s' " , wantMsg , tb .msg )
487+ t .Errorf ("got: %q; want: %q " , tb .msg , wantMsg )
488488 }
489489 })
490490 })
@@ -507,8 +507,9 @@ func TestTrue(t *testing.T) {
507507 if tb .fatal {
508508 t .Error ("should not be fatal" )
509509 }
510- if tb .msg != "not true" {
511- t .Errorf ("expected 'not true', got '%s'" , tb .msg )
510+ wantMsg := "got: false; want: true"
511+ if tb .msg != wantMsg {
512+ t .Errorf ("got: %q; want: %q" , tb .msg , wantMsg )
512513 }
513514 })
514515 t .Run ("expression" , func (t * testing.T ) {
0 commit comments