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

Function TestIntSetUnmarshalJSON

pkg/set/intset_test.go:45–63  ·  view source on GitHub ↗

IntSet.UnmarshalJSON() 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

43
44// IntSet.UnmarshalJSON() is called with series of cases for valid and erroneous inputs and the result is validated.
45func 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.
66func TestIntSetString(t *testing.T) {

Callers

nothing calls this directly

Calls 2

UnmarshalJSONMethod · 0.95
StringMethod · 0.95

Tested by

no test coverage detected