MCPcopy
hub / github.com/minio/minio-go / TestStringSetApplyFunc

Function TestStringSetApplyFunc

pkg/set/stringset_test.go:149–167  ·  view source on GitHub ↗

StringSet.ApplyFunc() is called with series of cases for valid and erroneous inputs and the result is validated.

(t *testing.T)

Source from the content-addressed store, hash-verified

147
148// StringSet.ApplyFunc() is called with series of cases for valid and erroneous inputs and the result is validated.
149func TestStringSetApplyFunc(t *testing.T) {
150 ss := CreateStringSet("foo", "bar")
151 testCases := []struct {
152 applyFn func(string) string
153 expectedResult string
154 }{
155 // Test to apply function prepending a known string.
156 {func(setValue string) string { return "mybucket/" + setValue }, `[mybucket/bar mybucket/foo]`},
157 // Test to apply function modifying values.
158 {func(setValue string) string { return setValue[1:] }, `[ar oo]`},
159 }
160
161 for _, testCase := range testCases {
162 s := ss.ApplyFunc(testCase.applyFn)
163 if result := s.String(); result != testCase.expectedResult {
164 t.Fatalf("expected: %s, got: %s", testCase.expectedResult, result)
165 }
166 }
167}
168
169// StringSet.Equals() is called with series of cases for valid and erroneous inputs and the result is validated.
170func TestStringSetEquals(t *testing.T) {

Callers

nothing calls this directly

Calls 3

CreateStringSetFunction · 0.85
ApplyFuncMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected