StringSet.ToSlice() is called with series of cases for valid and erroneous inputs and the result is validated.
(t *testing.T)
| 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) { |
| 330 | testCases := []struct { |
| 331 | set StringSet |
| 332 | expectedResult string |
| 333 | }{ |
| 334 | // Test empty set. |
| 335 | {NewStringSet(), `[]`}, |
| 336 | // Test set with empty value. |
| 337 | {CreateStringSet(""), `[]`}, |
| 338 | // Test set with value. |
| 339 | {CreateStringSet("foo"), `[foo]`}, |
| 340 | // Test set with value. |
| 341 | {CreateStringSet("foo", "bar"), `[bar foo]`}, |
| 342 | } |
| 343 | |
| 344 | for _, testCase := range testCases { |
| 345 | sslice := testCase.set.ToSlice() |
| 346 | if str := fmt.Sprintf("%s", sslice); str != testCase.expectedResult { |
| 347 | t.Fatalf("expected: %s, got: %s", testCase.expectedResult, str) |
| 348 | } |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | func TestStringSet_UnmarshalJSON(t *testing.T) { |
| 353 | type args struct { |
nothing calls this directly
no test coverage detected