MCPcopy
hub / github.com/minio/minio-go / TestStringSetMarshalJSON

Function TestStringSetMarshalJSON

pkg/set/stringset_test.go:264–280  ·  view source on GitHub ↗

StringSet.MarshalJSON() is called with series of cases for valid and erroneous inputs and the result is validated.

(t *testing.T)

Source from the content-addressed store, hash-verified

262
263// StringSet.MarshalJSON() is called with series of cases for valid and erroneous inputs and the result is validated.
264func 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.
283func TestStringSetUnmarshalJSON(t *testing.T) {

Callers

nothing calls this directly

Calls 3

CreateStringSetFunction · 0.85
NewStringSetFunction · 0.85
MarshalJSONMethod · 0.45

Tested by

no test coverage detected