List: add cap (#51)

Cap return cap of the inner data
This commit is contained in:
donutloop authored and GitHub committed 2022-07-25 20:50:31 +08:00
1 parent 3d7600a9e4
commit c1b7500bcb
3 files changed
+48

No files matched your search

+12
View File
@@ -261,6 +261,18 @@ func TestSize(t *testing.T) {
assert.Equal(0, empty.Size())
}
func TestCap(t *testing.T) {
assert := internal.NewAssert(t, "TestCap")
data := make([]int, 0, 100)
list := NewList(data)
assert.Equal(100, list.Cap())
data = make([]int, 0)
list = NewList(data)
assert.Equal(0, list.Cap())
}
func TestSwap(t *testing.T) {
assert := internal.NewAssert(t, "TestSwap")