1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 00:22:41 +08:00
Files
go-mixed/collections/linked_list_test.go
2022-06-07 10:58:21 +08:00

37 lines
525 B
Go

package collections
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewLinkdList(t *testing.T) {
l := NewLinkedList(1, 2, 3, 4, 5)
l.Append(55)
t.Log(l)
t.Log(NewLinkedList("a", "b", "c", "d"))
}
func TestLinkedListSize(t *testing.T) {
ll := NewLinkedList[int]()
ll.Append(5)
ll.Append(6)
ll.Append(7)
assert.Equal(t, 3, ll.Size())
ll.Prepend(8, 9, 10)
assert.Equal(t, 6, ll.Size())
ll.RemoveAt(1)
assert.Equal(t, 5, ll.Size())
t.Log(ll)
ll.RemoveAt(ll.Size() - 1)
t.Log(ll)
}