MCPcopy Create free account
hub / github.com/tinylib/msgp / TestInt16Sorted_NilHandling

Function TestInt16Sorted_NilHandling

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

Source from the content-addressed store, hash-verified

4261}
4262
4263func TestInt16Sorted_NilHandling(t *testing.T) {
4264 var nilSet Int16Sorted
4265
4266 // Test nil encoding
4267 var buf bytes.Buffer
4268 writer := msgp.NewWriter(&buf)
4269 err := nilSet.EncodeMsg(writer)
4270 if err != nil {
4271 t.Fatalf("EncodeMsg failed for nil: %v", err)
4272 }
4273 writer.Flush()
4274
4275 // Test nil decoding
4276 reader := msgp.NewReader(&buf)
4277 var decoded Int16Sorted
4278 err = decoded.DecodeMsg(reader)
4279 if err != nil {
4280 t.Fatalf("DecodeMsg failed for nil: %v", err)
4281 }
4282
4283 if decoded != nil {
4284 t.Fatal("expected nil, got non-nil")
4285 }
4286
4287 // Test nil marshaling
4288 data, err := nilSet.MarshalMsg(nil)
4289 if err != nil {
4290 t.Fatalf("MarshalMsg failed for nil: %v", err)
4291 }
4292
4293 // Test nil unmarshaling
4294 var unmarshaled Int16Sorted
4295 _, err = unmarshaled.UnmarshalMsg(data)
4296 if err != nil {
4297 t.Fatalf("UnmarshalMsg failed for nil: %v", err)
4298 }
4299
4300 if unmarshaled != nil {
4301 t.Fatal("expected nil, got non-nil")
4302 }
4303
4304 // Test AsSlice on nil
4305 slice := nilSet.AsSlice()
4306 if slice != nil {
4307 t.Fatal("expected nil slice, got non-nil")
4308 }
4309
4310 // Test FromSlice with nil
4311 fromNilSlice := Int16SortedFromSlice(nil)
4312 if fromNilSlice != nil {
4313 t.Fatal("expected nil from nil slice, got non-nil")
4314 }
4315}
4316
4317func TestInt16Sorted_EmptySet(t *testing.T) {
4318 set := make(Int16Sorted)

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…