(t *testing.T)
| 2183 | } |
| 2184 | |
| 2185 | func TestLen(t *testing.T) { |
| 2186 | t.Parallel() |
| 2187 | |
| 2188 | mockT := new(testing.T) |
| 2189 | |
| 2190 | False(t, Len(mockT, nil, 0), "nil does not have length") |
| 2191 | False(t, Len(mockT, 0, 0), "int does not have length") |
| 2192 | False(t, Len(mockT, true, 0), "true does not have length") |
| 2193 | False(t, Len(mockT, false, 0), "false does not have length") |
| 2194 | False(t, Len(mockT, 'A', 0), "Rune does not have length") |
| 2195 | False(t, Len(mockT, struct{}{}, 0), "Struct does not have length") |
| 2196 | |
| 2197 | ch := make(chan int, 5) |
| 2198 | ch <- 1 |
| 2199 | ch <- 2 |
| 2200 | ch <- 3 |
| 2201 | |
| 2202 | cases := []struct { |
| 2203 | v interface{} |
| 2204 | l int |
| 2205 | expected1234567 string // message when expecting 1234567 items |
| 2206 | }{ |
| 2207 | {[]int{1, 2, 3}, 3, `"[1 2 3]" should have 1234567 item(s), but has 3`}, |
| 2208 | {[...]int{1, 2, 3}, 3, `"[1 2 3]" should have 1234567 item(s), but has 3`}, |
| 2209 | {"ABC", 3, `"ABC" should have 1234567 item(s), but has 3`}, |
| 2210 | {map[int]int{1: 2, 2: 4, 3: 6}, 3, `"map[1:2 2:4 3:6]" should have 1234567 item(s), but has 3`}, |
| 2211 | {ch, 3, ""}, |
| 2212 | |
| 2213 | {[]int{}, 0, `"[]" should have 1234567 item(s), but has 0`}, |
| 2214 | {map[int]int{}, 0, `"map[]" should have 1234567 item(s), but has 0`}, |
| 2215 | {make(chan int), 0, ""}, |
| 2216 | |
| 2217 | {[]int(nil), 0, `"[]" should have 1234567 item(s), but has 0`}, |
| 2218 | {map[int]int(nil), 0, `"map[]" should have 1234567 item(s), but has 0`}, |
| 2219 | {(chan int)(nil), 0, `"<nil>" should have 1234567 item(s), but has 0`}, |
| 2220 | } |
| 2221 | |
| 2222 | for _, c := range cases { |
| 2223 | True(t, Len(mockT, c.v, c.l), "%#v have %d items", c.v, c.l) |
| 2224 | False(t, Len(mockT, c.v, c.l+1), "%#v have %d items", c.v, c.l) |
| 2225 | if c.expected1234567 != "" { |
| 2226 | msgMock := new(mockTestingT) |
| 2227 | Len(msgMock, c.v, 1234567) |
| 2228 | Contains(t, msgMock.errorString(), c.expected1234567) |
| 2229 | } |
| 2230 | } |
| 2231 | } |
| 2232 | |
| 2233 | func TestWithinDuration(t *testing.T) { |
| 2234 | t.Parallel() |
nothing calls this directly
no test coverage detected