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

Function TestByteSorted_NilHandling

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

Source from the content-addressed store, hash-verified

2281}
2282
2283func TestByteSorted_NilHandling(t *testing.T) {
2284 var nilSet ByteSorted
2285
2286 // Test nil encoding
2287 var buf bytes.Buffer
2288 writer := msgp.NewWriter(&buf)
2289 err := nilSet.EncodeMsg(writer)
2290 if err != nil {
2291 t.Fatalf("EncodeMsg failed for nil: %v", err)
2292 }
2293 writer.Flush()
2294
2295 // Test nil decoding
2296 reader := msgp.NewReader(&buf)
2297 var decoded ByteSorted
2298 err = decoded.DecodeMsg(reader)
2299 if err != nil {
2300 t.Fatalf("DecodeMsg failed for nil: %v", err)
2301 }
2302
2303 if decoded != nil {
2304 t.Fatal("expected nil, got non-nil")
2305 }
2306
2307 // Test nil marshaling
2308 data, err := nilSet.MarshalMsg(nil)
2309 if err != nil {
2310 t.Fatalf("MarshalMsg failed for nil: %v", err)
2311 }
2312
2313 // Test nil unmarshaling
2314 var unmarshaled ByteSorted
2315 _, err = unmarshaled.UnmarshalMsg(data)
2316 if err != nil {
2317 t.Fatalf("UnmarshalMsg failed for nil: %v", err)
2318 }
2319
2320 if unmarshaled != nil {
2321 t.Fatal("expected nil, got non-nil")
2322 }
2323
2324 // Test AsSlice on nil
2325 slice := nilSet.AsSlice()
2326 if slice != nil {
2327 t.Fatal("expected nil slice, got non-nil")
2328 }
2329
2330 // Test FromSlice with nil
2331 fromNilSlice := ByteSortedFromSlice(nil)
2332 if fromNilSlice != nil {
2333 t.Fatal("expected nil from nil slice, got non-nil")
2334 }
2335}
2336
2337func TestByteSorted_EmptySet(t *testing.T) {
2338 set := make(ByteSorted)

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
ByteSortedFromSliceFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…