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