MCPcopy Create free account
hub / github.com/CrowdStrike/csproto / TestEncodeBytes

Function TestEncodeBytes

encoder_test.go:86–113  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

84}
85
86func TestEncodeBytes(t *testing.T) {
87 cases := []struct {
88 name string
89 fieldNum int
90 v []byte
91 expected []byte
92 }{
93 {
94 name: "empty slice",
95 fieldNum: 1,
96 v: []byte{},
97 expected: []byte{0xA, 0x0},
98 },
99 {
100 name: "non-empty slice",
101 fieldNum: 2,
102 v: []byte{0x42, 0x11, 0x38},
103 expected: []byte{0x12, 0x3, 0x42, 0x11, 0x38},
104 },
105 }
106 for _, tc := range cases {
107 t.Run(tc.name, func(t *testing.T) {
108 dest := make([]byte, len(tc.expected))
109 csproto.NewEncoder(dest).EncodeBytes(tc.fieldNum, tc.v)
110 assert.Equal(t, tc.expected, dest)
111 })
112 }
113}
114
115func TestEncodeInt32(t *testing.T) {
116 cases := []struct {

Callers

nothing calls this directly

Calls 2

NewEncoderFunction · 0.92
EncodeBytesMethod · 0.80

Tested by

no test coverage detected