StringSet.FuncMatch() is called with series of cases for valid and erroneous inputs and the result is validated.
(t *testing.T)
| 121 | |
| 122 | // StringSet.FuncMatch() is called with series of cases for valid and erroneous inputs and the result is validated. |
| 123 | func 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. |
| 149 | func TestStringSetApplyFunc(t *testing.T) { |
nothing calls this directly
no test coverage detected