Len asserts that the specified object has specific length. Len also fails if the object has a type that len() not accept. assert.Len(t, mySlice, 3)
(t TestingT, object interface{}, length int, msgAndArgs ...interface{})
| 792 | // |
| 793 | // assert.Len(t, mySlice, 3) |
| 794 | func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) bool { |
| 795 | if h, ok := t.(tHelper); ok { |
| 796 | h.Helper() |
| 797 | } |
| 798 | l, ok := getLen(object) |
| 799 | if !ok { |
| 800 | return Fail(t, fmt.Sprintf("\"%v\" could not be applied builtin len()", object), msgAndArgs...) |
| 801 | } |
| 802 | |
| 803 | if l != length { |
| 804 | return Fail(t, fmt.Sprintf("\"%v\" should have %d item(s), but has %d", object, length, l), msgAndArgs...) |
| 805 | } |
| 806 | return true |
| 807 | } |
| 808 | |
| 809 | // True asserts that the specified value is true. |
| 810 | // |