| 388 | } |
| 389 | |
| 390 | func TestLenWrapper(t *testing.T) { |
| 391 | assert := New(t) |
| 392 | mockAssert := New(new(testing.T)) |
| 393 | |
| 394 | assert.False(mockAssert.Len(nil, 0), "nil does not have length") |
| 395 | assert.False(mockAssert.Len(0, 0), "int does not have length") |
| 396 | assert.False(mockAssert.Len(true, 0), "true does not have length") |
| 397 | assert.False(mockAssert.Len(false, 0), "false does not have length") |
| 398 | assert.False(mockAssert.Len('A', 0), "Rune does not have length") |
| 399 | assert.False(mockAssert.Len(struct{}{}, 0), "Struct does not have length") |
| 400 | |
| 401 | ch := make(chan int, 5) |
| 402 | ch <- 1 |
| 403 | ch <- 2 |
| 404 | ch <- 3 |
| 405 | |
| 406 | cases := []struct { |
| 407 | v interface{} |
| 408 | l int |
| 409 | }{ |
| 410 | {[]int{1, 2, 3}, 3}, |
| 411 | {[...]int{1, 2, 3}, 3}, |
| 412 | {"ABC", 3}, |
| 413 | {map[int]int{1: 2, 2: 4, 3: 6}, 3}, |
| 414 | {ch, 3}, |
| 415 | |
| 416 | {[]int{}, 0}, |
| 417 | {map[int]int{}, 0}, |
| 418 | {make(chan int), 0}, |
| 419 | |
| 420 | {[]int(nil), 0}, |
| 421 | {map[int]int(nil), 0}, |
| 422 | {(chan int)(nil), 0}, |
| 423 | } |
| 424 | |
| 425 | for _, c := range cases { |
| 426 | assert.True(mockAssert.Len(c.v, c.l), "%#v have %d items", c.v, c.l) |
| 427 | } |
| 428 | } |
| 429 | |
| 430 | func TestWithinDurationWrapper(t *testing.T) { |
| 431 | assert := New(t) |