@@ -157,6 +157,86 @@ func TestServerCapabilitiesMarshal(t *testing.T) {
157157 }
158158}
159159
160+ func TestSemanticTokensRequestsUnmarshal (t * testing.T ) {
161+ tests := []struct {
162+ name string
163+ input string
164+ check func (t * testing.T , r SemanticTokensRequestsCapabilities )
165+ wantErr bool
166+ }{
167+ {
168+ name : "full as true" ,
169+ input : `{"requests":{"full":true}}` ,
170+ check : func (t * testing.T , r SemanticTokensRequestsCapabilities ) {
171+ if r .Full == nil {
172+ t .Fatal ("full should be non-nil for boolean true" )
173+ }
174+ if r .Full .Delta != nil {
175+ t .Errorf ("delta should be nil, got %v" , * r .Full .Delta )
176+ }
177+ },
178+ },
179+ {
180+ name : "full as false" ,
181+ input : `{"requests":{"full":false}}` ,
182+ check : func (t * testing.T , r SemanticTokensRequestsCapabilities ) {
183+ if r .Full != nil {
184+ t .Errorf ("full should be nil for boolean false, got %+v" , r .Full )
185+ }
186+ },
187+ },
188+ {
189+ name : "full as object with delta" ,
190+ input : `{"requests":{"full":{"delta":true}}}` ,
191+ check : func (t * testing.T , r SemanticTokensRequestsCapabilities ) {
192+ if r .Full == nil || r .Full .Delta == nil || ! * r .Full .Delta {
193+ t .Fatalf ("delta not preserved, got %+v" , r .Full )
194+ }
195+ },
196+ },
197+ {
198+ name : "range as boolean" ,
199+ input : `{"requests":{"range":true}}` ,
200+ check : func (t * testing.T , r SemanticTokensRequestsCapabilities ) {
201+ if r .Range == nil || ! * r .Range {
202+ t .Fatalf ("range not preserved, got %+v" , r .Range )
203+ }
204+ },
205+ },
206+ {
207+ name : "range as empty object" ,
208+ input : `{"requests":{"range":{}}}` ,
209+ check : func (t * testing.T , r SemanticTokensRequestsCapabilities ) {
210+ if r .Range == nil || ! * r .Range {
211+ t .Fatalf ("range {} should mean supported, got %+v" , r .Range )
212+ }
213+ },
214+ },
215+ {
216+ name : "full as invalid" ,
217+ input : `{"requests":{"full":"nonsense"}}` ,
218+ wantErr : true ,
219+ },
220+ }
221+
222+ for _ , tc := range tests {
223+ t .Run (tc .name , func (t * testing.T ) {
224+ var caps SemanticTokensClientCapabilities
225+ err := json .Unmarshal ([]byte (tc .input ), & caps )
226+ if tc .wantErr {
227+ if err == nil {
228+ t .Fatal ("expected error, got nil" )
229+ }
230+ return
231+ }
232+ if err != nil {
233+ t .Fatalf ("unmarshal: %v" , err )
234+ }
235+ tc .check (t , caps .Requests )
236+ })
237+ }
238+ }
239+
160240func TestPositionEncodingCapabilitiesMarshal (t * testing.T ) {
161241 caps := ClientCapabilities {
162242 General : & GeneralClientCapabilities {
0 commit comments