StringSet.MarshalJSON() is called with series of cases for valid and erroneous inputs and the result is validated.
(t *testing.T)
| 262 | |
| 263 | // StringSet.MarshalJSON() is called with series of cases for valid and erroneous inputs and the result is validated. |
| 264 | func TestStringSetMarshalJSON(t *testing.T) { |
| 265 | testCases := []struct { |
| 266 | set StringSet |
| 267 | expectedResult string |
| 268 | }{ |
| 269 | // Test set with values. |
| 270 | {CreateStringSet("foo", "bar"), `["bar","foo"]`}, |
| 271 | // Test empty set. |
| 272 | {NewStringSet(), "[]"}, |
| 273 | } |
| 274 | |
| 275 | for _, testCase := range testCases { |
| 276 | if result, _ := testCase.set.MarshalJSON(); string(result) != testCase.expectedResult { |
| 277 | t.Fatalf("expected: %s, got: %s", testCase.expectedResult, string(result)) |
| 278 | } |
| 279 | } |
| 280 | } |
| 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) { |
nothing calls this directly
no test coverage detected