|
|
|
@ -6,11 +6,36 @@ package arraylist
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/emirpasic/gods/utils"
|
|
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestListNew(t *testing.T) {
|
|
|
|
|
list1 := New()
|
|
|
|
|
|
|
|
|
|
if actualValue := list1.Empty(); actualValue != true {
|
|
|
|
|
t.Errorf("Got %v expected %v", actualValue, true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
list2 := New(1, "b")
|
|
|
|
|
|
|
|
|
|
if actualValue := list2.Size(); actualValue != 2 {
|
|
|
|
|
t.Errorf("Got %v expected %v", actualValue, 2)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if actualValue, ok := list2.Get(0); actualValue != 1 || !ok {
|
|
|
|
|
t.Errorf("Got %v expected %v", actualValue, 1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if actualValue, ok := list2.Get(1); actualValue != "b" || !ok {
|
|
|
|
|
t.Errorf("Got %v expected %v", actualValue, "b")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if actualValue, ok := list2.Get(2); actualValue != nil || ok {
|
|
|
|
|
t.Errorf("Got %v expected %v", actualValue, nil)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestListAdd(t *testing.T) {
|
|
|
|
|
list := New()
|
|
|
|
|
list.Add("a")
|
|
|
|
|