StringSet.UnmarshalJSON() is called with series of cases for valid and erroneous inputs and the result is validated.
(t *testing.T)
| 281 | |
| 282 | // StringSet.UnmarshalJSON() is called with series of cases for valid and erroneous inputs and the result is validated. |
| 283 | func TestStringSetUnmarshalJSON(t *testing.T) { |
| 284 | testCases := []struct { |
| 285 | data []byte |
| 286 | expectedResult string |
| 287 | }{ |
| 288 | // Test to convert JSON array to set. |
| 289 | {[]byte(`["bar","foo"]`), `[bar foo]`}, |
| 290 | // Test to convert JSON string to set. |
| 291 | {[]byte(`"bar"`), `[bar]`}, |
| 292 | // Test to convert JSON empty array to set. |
| 293 | {[]byte(`[]`), `[]`}, |
| 294 | // Test to convert JSON empty string to set. |
| 295 | {[]byte(`""`), `[]`}, |
| 296 | } |
| 297 | |
| 298 | for _, testCase := range testCases { |
| 299 | var set StringSet |
| 300 | set.UnmarshalJSON(testCase.data) |
| 301 | if result := set.String(); result != testCase.expectedResult { |
| 302 | t.Fatalf("expected: %s, got: %s", testCase.expectedResult, result) |
| 303 | } |
| 304 | } |
| 305 | } |
| 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) { |
nothing calls this directly
no test coverage detected