StringSet.String() is called with series of cases for valid and erroneous inputs and the result is validated.
(t *testing.T)
| 306 | |
| 307 | // StringSet.String() is called with series of cases for valid and erroneous inputs and the result is validated. |
| 308 | func TestStringSetString(t *testing.T) { |
| 309 | testCases := []struct { |
| 310 | set StringSet |
| 311 | expectedResult string |
| 312 | }{ |
| 313 | // Test empty set. |
| 314 | {NewStringSet(), `[]`}, |
| 315 | // Test set with empty value. |
| 316 | {CreateStringSet(""), `[]`}, |
| 317 | // Test set with value. |
| 318 | {CreateStringSet("foo"), `[foo]`}, |
| 319 | } |
| 320 | |
| 321 | for _, testCase := range testCases { |
| 322 | if str := testCase.set.String(); str != testCase.expectedResult { |
| 323 | t.Fatalf("expected: %s, got: %s", testCase.expectedResult, str) |
| 324 | } |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | // StringSet.ToSlice() is called with series of cases for valid and erroneous inputs and the result is validated. |
| 329 | func TestStringSetToSlice(t *testing.T) { |
nothing calls this directly
no test coverage detected