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

Function TestStringSetFuncMatch

pkg/set/stringset_test.go:123–146  ·  view source on GitHub ↗

StringSet.FuncMatch() 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

121
122// StringSet.FuncMatch() is called with series of cases for valid and erroneous inputs and the result is validated.
123func TestStringSetFuncMatch(t *testing.T) {
124 ss := CreateStringSet("foo", "bar")
125 testCases := []struct {
126 matchFn func(string, string) bool
127 value string
128 expectedResult string
129 }{
130 // Test to check match function doing case insensive compare.
131 {func(setValue, compareValue string) bool {
132 return strings.EqualFold(setValue, compareValue)
133 }, "Bar", `[bar]`},
134 // Test to check match function doing prefix check.
135 {func(setValue, compareValue string) bool {
136 return strings.HasPrefix(compareValue, setValue)
137 }, "foobar", `[foo]`},
138 }
139
140 for _, testCase := range testCases {
141 s := ss.FuncMatch(testCase.matchFn, testCase.value)
142 if result := s.String(); result != testCase.expectedResult {
143 t.Fatalf("expected: %s, got: %s", testCase.expectedResult, result)
144 }
145 }
146}
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) {

Callers

nothing calls this directly

Calls 3

CreateStringSetFunction · 0.85
FuncMatchMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected