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{})
| 831 | // |
| 832 | // assert.Len(t, mySlice, 3) |
| 833 | func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) bool { |
| 834 | if h, ok := t.(tHelper); ok { |
| 835 | h.Helper() |
| 836 | } |
| 837 | l, ok := getLen(object) |
| 838 | if !ok { |
| 839 | return Fail(t, fmt.Sprintf("\"%v\" could not be applied builtin len()", object), msgAndArgs...) |
| 840 | } |
| 841 | |
| 842 | if l != length { |
| 843 | return Fail(t, fmt.Sprintf("\"%v\" should have %d item(s), but has %d", object, length, l), msgAndArgs...) |
| 844 | } |
| 845 | return true |
| 846 | } |
| 847 | |
| 848 | // True asserts that the specified value is true. |
| 849 | // |