IntSet.UnmarshalJSON() is called with series of cases for valid and erroneous inputs and the result is validated.
(t *testing.T)
| 43 | |
| 44 | // IntSet.UnmarshalJSON() is called with series of cases for valid and erroneous inputs and the result is validated. |
| 45 | func TestIntSetUnmarshalJSON(t *testing.T) { |
| 46 | testCases := []struct { |
| 47 | data []byte |
| 48 | expectedResult string |
| 49 | }{ |
| 50 | // Test to convert JSON array to set. |
| 51 | {[]byte(`[1,2,3]`), `[1 2 3]`}, |
| 52 | // Test to convert JSON empty array to set. |
| 53 | {[]byte(`[]`), `[]`}, |
| 54 | } |
| 55 | |
| 56 | for _, testCase := range testCases { |
| 57 | var set IntSet |
| 58 | set.UnmarshalJSON(testCase.data) |
| 59 | if result := set.String(); result != testCase.expectedResult { |
| 60 | t.Fatalf("expected: %s, got: %s", testCase.expectedResult, result) |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | // IntSet.String() is called with series of cases for valid and erroneous inputs and the result is validated. |
| 66 | func TestIntSetString(t *testing.T) { |
nothing calls this directly
no test coverage detected