Skip to content

Commit

Permalink
Merge 2eb52e2 into ca1ec5a
Browse files Browse the repository at this point in the history
  • Loading branch information
liquidgecka committed Nov 18, 2016
2 parents ca1ec5a + 2eb52e2 commit 098253f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
15 changes: 10 additions & 5 deletions equal.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,16 +317,22 @@ func (t *T) deepEqual(
// and assert to a string will panic.
hstr := have.String()
wstr := want.String()
if len(hstr) != len(wstr) {
if hstr == wstr {
// Cheap equality test passed, no need to continue.
break
}
hrunes := []rune(hstr)
wrunes := []rune(wstr)
if len(hrunes) != len(wrunes) {
return []string{
fmt.Sprintf("%s: len(have) %d != len(want) %d.",
desc, len(hstr), len(wstr)),
desc, len(hrunes), len(wrunes)),
fmt.Sprintf(" have: %#v", hstr),
fmt.Sprintf(" want: %#v", wstr),
}
}
for i := range hstr {
if hstr[i] != wstr[i] {
for i, r := range hrunes {
if r != wrunes[i] {
return []string{
fmt.Sprintf("%s: difference at index %d.", desc, i),
fmt.Sprintf(" have: %#v", hstr),
Expand Down Expand Up @@ -446,6 +452,5 @@ func (t *T) deepEqual(
}
}

// This shouldn't ever be reached.
return diffs
}
5 changes: 5 additions & 0 deletions equal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ func TestT_EqualAndNotEqual(t *testing.T) {
[]interface{}{"", d1, d2, d3})
}

// Unicode strings + Regressions
runTest(
[]interface{}{"└"},
[]interface{}{"╰"})

// Boolean (no need to test with 100 values.)
runTest(
[]interface{}{true},
Expand Down

0 comments on commit 098253f

Please sign in to comment.