mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-08 05:50:47 +00:00
Check string in slice.
This commit is contained in:
+10
-1
@@ -51,5 +51,14 @@ func StrMapsEqual(m1, m2 map[string]string) bool {
|
||||
}
|
||||
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
// StrSliceHasItem checks item for presence in slice
|
||||
func StrSliceHasItem(s []string, item string) bool {
|
||||
for _, v := range s {
|
||||
if v == item {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -37,3 +37,8 @@ func (s *ListSuite) TestStrMapsEqual(c *C) {
|
||||
c.Check(StrMapsEqual(map[string]string{"a": "1", "b": "2"}, map[string]string{"a": "1", "c": "2"}), Equals, false)
|
||||
c.Check(StrMapsEqual(map[string]string{"a": "1", "b": "2"}, map[string]string{"a": "1"}), Equals, false)
|
||||
}
|
||||
|
||||
func (s *ListSuite) TestStrSliceHasIteml(c *C) {
|
||||
c.Check(StrSliceHasItem([]string{"a", "b"}, "b"), Equals, true)
|
||||
c.Check(StrSliceHasItem([]string{"a", "b"}, "c"), Equals, false)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user