Copy Inslice() to those parts that use it
Signed-off-by: Chao Wang <wangchao.fnst@cn.fujitsu.com> Upstream-commit: 5c154cfac89305f7ca9446854e56700e8a660f93 Component: engine
This commit is contained in:
@ -41,17 +41,6 @@ func Truncate(s string, maxlen int) string {
|
||||
return string(r[:maxlen])
|
||||
}
|
||||
|
||||
// InSlice tests whether a string is contained in a slice of strings or not.
|
||||
// Comparison is case insensitive
|
||||
func InSlice(slice []string, s string) bool {
|
||||
for _, ss := range slice {
|
||||
if strings.ToLower(s) == strings.ToLower(ss) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func quote(word string, buf *bytes.Buffer) {
|
||||
// Bail out early for "simple" strings
|
||||
if word != "" && !strings.ContainsAny(word, "\\'\"`${[|&;<>()~*?! \t\n") {
|
||||
|
||||
@ -77,23 +77,6 @@ func TestTruncate(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestInSlice(t *testing.T) {
|
||||
slice := []string{"t🐳st", "in", "slice"}
|
||||
|
||||
test := InSlice(slice, "t🐳st")
|
||||
if !test {
|
||||
t.Fatalf("Expected string t🐳st to be in slice")
|
||||
}
|
||||
test = InSlice(slice, "SLICE")
|
||||
if !test {
|
||||
t.Fatalf("Expected string SLICE to be in slice")
|
||||
}
|
||||
test = InSlice(slice, "notinslice")
|
||||
if test {
|
||||
t.Fatalf("Expected string notinslice not to be in slice")
|
||||
}
|
||||
}
|
||||
|
||||
func TestShellQuoteArgumentsEmpty(t *testing.T) {
|
||||
actual := ShellQuoteArguments([]string{})
|
||||
expected := ""
|
||||
|
||||
Reference in New Issue
Block a user