Merge pull request #205 from emirpasic/development

Fix in ArrayList.Contains function against nil values
pull/210/head v1.18.1
Emir Pasic 2 years ago committed by GitHub
commit dbdbadc158
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -82,8 +82,8 @@ func (list *List) Contains(values ...interface{}) bool {
for _, searchValue := range values {
found := false
for _, element := range list.elements {
if element == searchValue {
for index := 0; index < list.size; index++ {
if list.elements[index] == searchValue {
found = true
break
}

@ -164,6 +164,9 @@ func TestListContains(t *testing.T) {
if actualValue := list.Contains("a"); actualValue != true {
t.Errorf("Got %v expected %v", actualValue, true)
}
if actualValue := list.Contains(nil); actualValue != false {
t.Errorf("Got %v expected %v", actualValue, false)
}
if actualValue := list.Contains("a", "b", "c"); actualValue != true {
t.Errorf("Got %v expected %v", actualValue, true)
}

Loading…
Cancel
Save