use slices package and remove some helpers (#17342)

This commit is contained in:
Harshavardhana
2023-06-06 10:12:52 -07:00
committed by GitHub
parent 5a21b1f353
commit d1448adbda
8 changed files with 42 additions and 50 deletions

View File

@@ -288,40 +288,6 @@ func TestToS3ETag(t *testing.T) {
}
}
// Test contains
func TestContains(t *testing.T) {
testErr := errors.New("test err")
testCases := []struct {
slice interface{}
elem interface{}
found bool
}{
{nil, nil, false},
{"1", "1", false},
{nil, "1", false},
{[]string{"1"}, nil, false},
{[]string{}, "1", false},
{[]string{"1"}, "1", true},
{[]string{"2"}, "1", false},
{[]string{"1", "2"}, "1", true},
{[]string{"2", "1"}, "1", true},
{[]string{"2", "1", "3"}, "1", true},
{[]int{1, 2, 3}, "1", false},
{[]int{1, 2, 3}, 2, true},
{[]int{1, 2, 3, 4, 5, 6}, 7, false},
{[]error{errors.New("new err")}, testErr, false},
{[]error{errors.New("new err"), testErr}, testErr, true},
}
for i, testCase := range testCases {
found := contains(testCase.slice, testCase.elem)
if found != testCase.found {
t.Fatalf("Test %v: expected: %v, got: %v", i+1, testCase.found, found)
}
}
}
// Test ceilFrac
func TestCeilFrac(t *testing.T) {
cases := []struct {