(t *testing.T)
| 1681 | } |
| 1682 | |
| 1683 | func TestLen(t *testing.T) { |
| 1684 | mockT := new(testing.T) |
| 1685 | |
| 1686 | False(t, Len(mockT, nil, 0), "nil does not have length") |
| 1687 | False(t, Len(mockT, 0, 0), "int does not have length") |
| 1688 | False(t, Len(mockT, true, 0), "true does not have length") |
| 1689 | False(t, Len(mockT, false, 0), "false does not have length") |
| 1690 | False(t, Len(mockT, 'A', 0), "Rune does not have length") |
| 1691 | False(t, Len(mockT, struct{}{}, 0), "Struct does not have length") |
| 1692 | |
| 1693 | ch := make(chan int, 5) |
| 1694 | ch <- 1 |
| 1695 | ch <- 2 |
| 1696 | ch <- 3 |
| 1697 | |
| 1698 | cases := []struct { |
| 1699 | v interface{} |
| 1700 | l int |
| 1701 | expected1234567 string // message when expecting 1234567 items |
| 1702 | }{ |
| 1703 | {[]int{1, 2, 3}, 3, `"[1 2 3]" should have 1234567 item(s), but has 3`}, |
| 1704 | {[...]int{1, 2, 3}, 3, `"[1 2 3]" should have 1234567 item(s), but has 3`}, |
| 1705 | {"ABC", 3, `"ABC" should have 1234567 item(s), but has 3`}, |
| 1706 | {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`}, |
| 1707 | {ch, 3, ""}, |
| 1708 | |
| 1709 | {[]int{}, 0, `"[]" should have 1234567 item(s), but has 0`}, |
| 1710 | {map[int]int{}, 0, `"map[]" should have 1234567 item(s), but has 0`}, |
| 1711 | {make(chan int), 0, ""}, |
| 1712 | |
| 1713 | {[]int(nil), 0, `"[]" should have 1234567 item(s), but has 0`}, |
| 1714 | {map[int]int(nil), 0, `"map[]" should have 1234567 item(s), but has 0`}, |
| 1715 | {(chan int)(nil), 0, `"<nil>" should have 1234567 item(s), but has 0`}, |
| 1716 | } |
| 1717 | |
| 1718 | for _, c := range cases { |
| 1719 | True(t, Len(mockT, c.v, c.l), "%#v have %d items", c.v, c.l) |
| 1720 | False(t, Len(mockT, c.v, c.l+1), "%#v have %d items", c.v, c.l) |
| 1721 | if c.expected1234567 != "" { |
| 1722 | msgMock := new(mockTestingT) |
| 1723 | Len(msgMock, c.v, 1234567) |
| 1724 | Contains(t, msgMock.errorString(), c.expected1234567) |
| 1725 | } |
| 1726 | } |
| 1727 | } |
| 1728 | |
| 1729 | func TestWithinDuration(t *testing.T) { |
| 1730 |
nothing calls this directly
no test coverage detected
searching dependent graphs…