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

Function TestEncodePackedInt32

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

Source from the content-addressed store, hash-verified

160}
161
162func TestEncodePackedInt32(t *testing.T) {
163 dest := make([]byte, 9)
164 enc := csproto.NewEncoder(dest)
165 enc.EncodePackedInt32(1, []int32{0, math.MaxInt32, 42})
166
167 expected := []byte{
168 // tag=1, wire type=2
169 0x0a,
170 // total length (7)
171 0x07,
172 // 0,
173 0x00,
174 // math.MaxInt32
175 0xFF, 0xFF, 0xFF, 0xFF, 0x07,
176 // 42
177 0x2A,
178 }
179 assert.Equal(t, expected, dest)
180}
181
182func TestEncodeInt64(t *testing.T) {
183 cases := []struct {

Callers

nothing calls this directly

Calls 2

EncodePackedInt32Method · 0.95
NewEncoderFunction · 0.92

Tested by

no test coverage detected