Skip to content
This repository has been archived by the owner on May 2, 2020. It is now read-only.

Commit

Permalink
Better fail message for Len()
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerb committed Jun 22, 2016
1 parent 0e2cbac commit e20cd91
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions is.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,9 @@ func (is *Is) Len(o interface{}, l int) {
fail(is, "expected object '%s' to be of length '%d', but the object is not one of array, slice or map", objectTypeName(o), l)
}

if reflect.ValueOf(o).Len() != l {
fail(is, "expected object '%s' to be of length '%d'", objectTypeName(o), l)
rLen := reflect.ValueOf(o).Len()
if rLen != l {
fail(is, "expected object '%s' to be of length '%d' but it was: %d", objectTypeName(o), l, rLen)
}
}

Expand Down

0 comments on commit e20cd91

Please sign in to comment.