MCPcopy
hub / github.com/gogo/protobuf / encodeMessageCheck

Function encodeMessageCheck

test/issue620/issue620_test.go:75–105  ·  view source on GitHub ↗
(t *testing.T, b1, b2 proto.Message, bufProto, bufProtoFast *proto.Buffer, exp []byte)

Source from the content-addressed store, hash-verified

73}
74
75func encodeMessageCheck(t *testing.T, b1, b2 proto.Message, bufProto, bufProtoFast *proto.Buffer, exp []byte) {
76 err := bufProto.EncodeMessage(b1)
77 errCheck(t, err)
78 err = bufProtoFast.EncodeMessage(b2)
79 errCheck(t, err)
80 checkEqual(t, exp, bufProto.Bytes())
81 checkEqual(t, exp, bufProtoFast.Bytes())
82
83 bufProto.Reset()
84 bufProtoFast.Reset()
85 expMore := make([]byte, 0, len(exp))
86 copy(expMore, exp)
87 for i := 0; i < 10; i++ {
88 err = bufProto.EncodeMessage(b1)
89 errCheck(t, err)
90 err = bufProtoFast.EncodeMessage(b2)
91 errCheck(t, err)
92 expMore = append(expMore, exp...)
93 checkEqual(t, expMore, bufProto.Bytes())
94 checkEqual(t, expMore, bufProtoFast.Bytes())
95 }
96
97 bufProto.Reset()
98 bufProtoFast.Reset()
99 err = bufProto.EncodeMessage(b1)
100 errCheck(t, err)
101 err = bufProtoFast.EncodeMessage(b2)
102 errCheck(t, err)
103 checkEqual(t, exp, bufProto.Bytes())
104 checkEqual(t, exp, bufProtoFast.Bytes())
105}
106
107func errCheck(t *testing.T, err error) {
108 t.Helper()

Callers 2

TestEncodeShortFunction · 0.85
TestEncodeLongFunction · 0.85

Calls 5

errCheckFunction · 0.85
checkEqualFunction · 0.85
EncodeMessageMethod · 0.80
ResetMethod · 0.65
BytesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…