MCPcopy Create free account
hub / github.com/modelcontextprotocol/go-sdk / TestNewDecoderCaseSensitivity

Function TestNewDecoderCaseSensitivity

internal/json/json_test.go:69–104  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

67}
68
69func TestNewDecoderCaseSensitivity(t *testing.T) {
70 type Target struct {
71 Field string `json:"field"`
72 TaggedField string `json:"custom_tag"`
73 }
74
75 tests := []struct {
76 name string
77 json string
78 want Target
79 }{
80 {
81 name: "exact match",
82 json: `{"field": "value", "custom_tag": "tagged"}`,
83 want: Target{Field: "value", TaggedField: "tagged"},
84 },
85 {
86 name: "case mismatch",
87 json: `{"Field": "value", "Custom_tag": "tagged"}`,
88 want: Target{},
89 },
90 }
91
92 for _, tt := range tests {
93 t.Run(tt.name, func(t *testing.T) {
94 var got Target
95 dec := NewDecoder(strings.NewReader(tt.json))
96 if err := dec.Decode(&got); err != nil {
97 t.Fatalf("Decode failed: %v", err)
98 }
99 if diff := cmp.Diff(tt.want, got); diff != "" {
100 t.Errorf("Decode mismatch (-want +got):\n%s", diff)
101 }
102 })
103 }
104}
105
106func TestUnmarshalNullCharacter(t *testing.T) {
107 type Target struct {

Callers

nothing calls this directly

Calls 3

DecodeMethod · 0.95
NewDecoderFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…