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

Function TestInt_NilHandling

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

Source from the content-addressed store, hash-verified

768}
769
770func TestInt_NilHandling(t *testing.T) {
771 var nilSet Int
772
773 // Test nil encoding
774 var buf bytes.Buffer
775 writer := msgp.NewWriter(&buf)
776 err := nilSet.EncodeMsg(writer)
777 if err != nil {
778 t.Fatalf("EncodeMsg failed for nil: %v", err)
779 }
780 writer.Flush()
781
782 // Test nil decoding
783 reader := msgp.NewReader(&buf)
784 var decoded Int
785 err = decoded.DecodeMsg(reader)
786 if err != nil {
787 t.Fatalf("DecodeMsg failed for nil: %v", err)
788 }
789
790 if decoded != nil {
791 t.Fatal("expected nil, got non-nil")
792 }
793
794 // Test nil marshaling
795 data, err := nilSet.MarshalMsg(nil)
796 if err != nil {
797 t.Fatalf("MarshalMsg failed for nil: %v", err)
798 }
799
800 // Test nil unmarshaling
801 var unmarshaled Int
802 _, err = unmarshaled.UnmarshalMsg(data)
803 if err != nil {
804 t.Fatalf("UnmarshalMsg failed for nil: %v", err)
805 }
806
807 if unmarshaled != nil {
808 t.Fatal("expected nil, got non-nil")
809 }
810
811 // Test AsSlice on nil
812 slice := nilSet.AsSlice()
813 if slice != nil {
814 t.Fatal("expected nil slice, got non-nil")
815 }
816
817 // Test FromSlice with nil
818 fromNilSlice := IntFromSlice(nil)
819 if fromNilSlice != nil {
820 t.Fatal("expected nil from nil slice, got non-nil")
821 }
822}
823
824func TestInt_EmptySet(t *testing.T) {
825 set := make(Int)

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…