IntSet.MarshalJSON() is called with series of cases for valid and erroneous inputs and the result is validated.
(t *testing.T)
| 24 | |
| 25 | // IntSet.MarshalJSON() is called with series of cases for valid and erroneous inputs and the result is validated. |
| 26 | func TestIntSetMarshalJSON(t *testing.T) { |
| 27 | testCases := []struct { |
| 28 | set IntSet |
| 29 | expectedResult string |
| 30 | }{ |
| 31 | // Test set with values. |
| 32 | {CreateIntSet(1, 2, 3), `[1,2,3]`}, |
| 33 | // Test empty set. |
| 34 | {NewIntSet(), "[]"}, |
| 35 | } |
| 36 | |
| 37 | for _, testCase := range testCases { |
| 38 | if result, _ := testCase.set.MarshalJSON(); string(result) != testCase.expectedResult { |
| 39 | t.Fatalf("expected: %s, got: %s", testCase.expectedResult, string(result)) |
| 40 | } |
| 41 | } |
| 42 | } |
| 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) { |
nothing calls this directly
no test coverage detected