MCPcopy
hub / github.com/golang/protobuf / overify

Function overify

proto/proto_test.go:100–126  ·  proto/proto_test.go::overify
(t *testing.T, pb *pb2.GoTest, want []byte)

Source from the content-addressed store, hash-verified

98}
99
100func overify(t *testing.T, pb *pb2.GoTest, want []byte) {
101 bb := new(proto.Buffer)
102 err := bb.Marshal(pb)
103 got := bb.Bytes()
104 if err != nil {
105 t.Logf("overify marshal-1 err = %v", err)
106 }
107 if !bytes.Equal(got, want) {
108 t.Fatalf("got %q\nwant %q", got, want)
109 }
110
111 // Now test Unmarshal by recreating the original buffer.
112 pbd := new(pb2.GoTest)
113 err = bb.Unmarshal(pbd)
114 if err != nil {
115 t.Fatalf("overify unmarshal err = %v", err)
116 }
117 bb.Reset()
118 err = bb.Marshal(pbd)
119 got = bb.Bytes()
120 if err != nil {
121 t.Fatalf("overify marshal-2 err = %v", err)
122 }
123 if !bytes.Equal(got, want) {
124 t.Fatalf("got %q\nwant %q", got, want)
125 }
126}
127
128// When hooks are enabled, RequiredNotSetError is typed alias to internal/proto
129// package. Binary serialization has not been wrapped yet and hence produces

Callers 6

TestEncodeDecode1Function · 0.85
TestEncodeDecode2Function · 0.85
TestEncodeDecode3Function · 0.85
TestEncodeDecode4Function · 0.85
TestEncodeDecode5Function · 0.85
TestEncodeDecode6Function · 0.85

Calls 4

BytesMethod · 0.80
MarshalMethod · 0.65
UnmarshalMethod · 0.65
ResetMethod · 0.45

Tested by

no test coverage detected