| 1568 | } |
| 1569 | |
| 1570 | func TestEmpty(t *testing.T) { |
| 1571 | |
| 1572 | mockT := new(testing.T) |
| 1573 | chWithValue := make(chan struct{}, 1) |
| 1574 | chWithValue <- struct{}{} |
| 1575 | var tiP *time.Time |
| 1576 | var tiNP time.Time |
| 1577 | var s *string |
| 1578 | var f *os.File |
| 1579 | sP := &s |
| 1580 | x := 1 |
| 1581 | xP := &x |
| 1582 | |
| 1583 | type TString string |
| 1584 | type TStruct struct { |
| 1585 | x int |
| 1586 | } |
| 1587 | |
| 1588 | True(t, Empty(mockT, ""), "Empty string is empty") |
| 1589 | True(t, Empty(mockT, nil), "Nil is empty") |
| 1590 | True(t, Empty(mockT, []string{}), "Empty string array is empty") |
| 1591 | True(t, Empty(mockT, 0), "Zero int value is empty") |
| 1592 | True(t, Empty(mockT, false), "False value is empty") |
| 1593 | True(t, Empty(mockT, make(chan struct{})), "Channel without values is empty") |
| 1594 | True(t, Empty(mockT, s), "Nil string pointer is empty") |
| 1595 | True(t, Empty(mockT, f), "Nil os.File pointer is empty") |
| 1596 | True(t, Empty(mockT, tiP), "Nil time.Time pointer is empty") |
| 1597 | True(t, Empty(mockT, tiNP), "time.Time is empty") |
| 1598 | True(t, Empty(mockT, TStruct{}), "struct with zero values is empty") |
| 1599 | True(t, Empty(mockT, TString("")), "empty aliased string is empty") |
| 1600 | True(t, Empty(mockT, sP), "ptr to nil value is empty") |
| 1601 | True(t, Empty(mockT, [1]int{}), "array is state") |
| 1602 | |
| 1603 | False(t, Empty(mockT, "something"), "Non Empty string is not empty") |
| 1604 | False(t, Empty(mockT, errors.New("something")), "Non nil object is not empty") |
| 1605 | False(t, Empty(mockT, []string{"something"}), "Non empty string array is not empty") |
| 1606 | False(t, Empty(mockT, 1), "Non-zero int value is not empty") |
| 1607 | False(t, Empty(mockT, true), "True value is not empty") |
| 1608 | False(t, Empty(mockT, chWithValue), "Channel with values is not empty") |
| 1609 | False(t, Empty(mockT, TStruct{x: 1}), "struct with initialized values is empty") |
| 1610 | False(t, Empty(mockT, TString("abc")), "non-empty aliased string is empty") |
| 1611 | False(t, Empty(mockT, xP), "ptr to non-nil value is not empty") |
| 1612 | False(t, Empty(mockT, [1]int{42}), "array is not state") |
| 1613 | } |
| 1614 | |
| 1615 | func TestNotEmpty(t *testing.T) { |
| 1616 | |