MCPcopy
hub / github.com/tinylib/msgp / TestStringSorted_NilHandling

Function TestStringSorted_NilHandling

msgp/setof/generated_test.go:303–355  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

301}
302
303func TestStringSorted_NilHandling(t *testing.T) {
304 var nilSet StringSorted
305
306 // Test nil encoding
307 var buf bytes.Buffer
308 writer := msgp.NewWriter(&buf)
309 err := nilSet.EncodeMsg(writer)
310 if err != nil {
311 t.Fatalf("EncodeMsg failed for nil: %v", err)
312 }
313 writer.Flush()
314
315 // Test nil decoding
316 reader := msgp.NewReader(&buf)
317 var decoded StringSorted
318 err = decoded.DecodeMsg(reader)
319 if err != nil {
320 t.Fatalf("DecodeMsg failed for nil: %v", err)
321 }
322
323 if decoded != nil {
324 t.Fatal("expected nil, got non-nil")
325 }
326
327 // Test nil marshaling
328 data, err := nilSet.MarshalMsg(nil)
329 if err != nil {
330 t.Fatalf("MarshalMsg failed for nil: %v", err)
331 }
332
333 // Test nil unmarshaling
334 var unmarshaled StringSorted
335 _, err = unmarshaled.UnmarshalMsg(data)
336 if err != nil {
337 t.Fatalf("UnmarshalMsg failed for nil: %v", err)
338 }
339
340 if unmarshaled != nil {
341 t.Fatal("expected nil, got non-nil")
342 }
343
344 // Test AsSlice on nil
345 slice := nilSet.AsSlice()
346 if slice != nil {
347 t.Fatal("expected nil slice, got non-nil")
348 }
349
350 // Test FromSlice with nil
351 fromNilSlice := StringSortedFromSlice(nil)
352 if fromNilSlice != nil {
353 t.Fatal("expected nil from nil slice, got non-nil")
354 }
355}
356
357func TestStringSorted_EmptySet(t *testing.T) {
358 set := make(StringSorted)

Callers

nothing calls this directly

Calls 9

EncodeMsgMethod · 0.95
FlushMethod · 0.95
DecodeMsgMethod · 0.95
MarshalMsgMethod · 0.95
UnmarshalMsgMethod · 0.95
AsSliceMethod · 0.95
NewWriterFunction · 0.92
NewReaderFunction · 0.92
StringSortedFromSliceFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…