Skip to content

Commit 3c1541a

Browse files
ccoVeilledolmen
andcommitted
Improve usage of Sprintf with Same/NotSame
Co-authored-by: Olivier Mengué <[email protected]>
1 parent c98ef6e commit 3c1541a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

assert/assertions.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -543,8 +543,9 @@ func Same(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) b
543543
if !same {
544544
// both are pointers but not the same type & pointing to the same address
545545
return Fail(t, fmt.Sprintf("Not same: \n"+
546-
"expected: %p %#v\n"+
547-
"actual : %p %#v", expected, expected, actual, actual), msgAndArgs...)
546+
"expected: %p %#[1]v\n"+
547+
"actual : %p %#[2]v",
548+
expected, actual), msgAndArgs...)
548549
}
549550

550551
return true
@@ -569,8 +570,8 @@ func NotSame(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}
569570

570571
if same {
571572
return Fail(t, fmt.Sprintf(
572-
"Expected and actual point to the same object: %p %#v",
573-
expected, expected), msgAndArgs...)
573+
"Expected and actual point to the same object: %p %#[1]v",
574+
expected), msgAndArgs...)
574575
}
575576
return true
576577
}

0 commit comments

Comments
 (0)