File tree 2 files changed +30
-2
lines changed
2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -137,8 +137,8 @@ want: %v
137
137
` ,
138
138
argGot ,
139
139
argWant ,
140
- quoteString (interface {} (got ).( string )),
141
- quoteString (interface {} (want ).( string )),
140
+ quoteString (reflect . ValueOf (got ).String ( )),
141
+ quoteString (reflect . ValueOf (want ).String ( )),
142
142
),
143
143
}
144
144
}
Original file line number Diff line number Diff line change @@ -146,6 +146,8 @@ diff (-want +got):
146
146
})
147
147
}
148
148
149
+ type CustomString string
150
+
149
151
func TestEqual (t * testing.T ) {
150
152
t .Run ("equal" , func (t * testing.T ) {
151
153
g := ghost .New (t )
@@ -310,6 +312,32 @@ diff (-want +got):
310
312
result .Message = strings .ReplaceAll (result .Message , "\u00a0 " , " " )
311
313
g .Should (be .Equal (result .Message , wantText ))
312
314
})
315
+
316
+ t .Run ("custom string type" , func (t * testing.T ) {
317
+ g := ghost .New (t )
318
+
319
+ type T struct {
320
+ A string
321
+ B int
322
+ }
323
+
324
+ got := CustomString ("foo" )
325
+ want := CustomString ("bar" )
326
+
327
+ result := be .Equal (got , want )
328
+ g .Should (be .False (result .Ok ))
329
+ g .Should (be .Equal (result .Message , `got != want
330
+ got: "foo"
331
+ want: "bar"
332
+ ` ))
333
+
334
+ result = be .Equal (CustomString ("foo" ), CustomString ("bar" ))
335
+ g .Should (be .False (result .Ok ))
336
+ g .Should (be .Equal (result .Message , `CustomString("foo") != CustomString("bar")
337
+ got: "foo"
338
+ want: "bar"
339
+ ` ))
340
+ })
313
341
}
314
342
315
343
func TestError (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments