| 426 | } |
| 427 | |
| 428 | func TestLenWrapper(t *testing.T) { |
| 429 | t.Parallel() |
| 430 | |
| 431 | assert := New(t) |
| 432 | mockAssert := New(new(testing.T)) |
| 433 | |
| 434 | assert.False(mockAssert.Len(nil, 0), "nil does not have length") |
| 435 | assert.False(mockAssert.Len(0, 0), "int does not have length") |
| 436 | assert.False(mockAssert.Len(true, 0), "true does not have length") |
| 437 | assert.False(mockAssert.Len(false, 0), "false does not have length") |
| 438 | assert.False(mockAssert.Len('A', 0), "Rune does not have length") |
| 439 | assert.False(mockAssert.Len(struct{}{}, 0), "Struct does not have length") |
| 440 | |
| 441 | ch := make(chan int, 5) |
| 442 | ch <- 1 |
| 443 | ch <- 2 |
| 444 | ch <- 3 |
| 445 | |
| 446 | cases := []struct { |
| 447 | v interface{} |
| 448 | l int |
| 449 | }{ |
| 450 | {[]int{1, 2, 3}, 3}, |
| 451 | {[...]int{1, 2, 3}, 3}, |
| 452 | {"ABC", 3}, |
| 453 | {map[int]int{1: 2, 2: 4, 3: 6}, 3}, |
| 454 | {ch, 3}, |
| 455 | |
| 456 | {[]int{}, 0}, |
| 457 | {map[int]int{}, 0}, |
| 458 | {make(chan int), 0}, |
| 459 | |
| 460 | {[]int(nil), 0}, |
| 461 | {map[int]int(nil), 0}, |
| 462 | {(chan int)(nil), 0}, |
| 463 | } |
| 464 | |
| 465 | for _, c := range cases { |
| 466 | assert.True(mockAssert.Len(c.v, c.l), "%#v have %d items", c.v, c.l) |
| 467 | } |
| 468 | } |
| 469 | |
| 470 | func TestWithinDurationWrapper(t *testing.T) { |
| 471 | t.Parallel() |