Files
utilities/Maps/maps_test.go

27 lines
648 B
Go

package Maps
import "testing"
func TestIsElementExist(t *testing.T) {
tests := []struct {
name string
s []string
str string
expected bool
}{
{"element exists", []string{"a", "b", "c"}, "b", true},
{"element does not exist", []string{"a", "b", "c"}, "d", false},
{"empty slice", []string{}, "a", false},
{"multiple same elements", []string{"a", "b", "a"}, "a", true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := IsElementExist(tt.s, tt.str)
if result != tt.expected {
t.Errorf("IsElementExist(%v, %q) = %v; want %v", tt.s, tt.str, result, tt.expected)
}
})
}
}