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

Function TestEncodeUInt32

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

Source from the content-addressed store, hash-verified

247}
248
249func TestEncodeUInt32(t *testing.T) {
250 cases := []struct {
251 name string
252 fieldNum int
253 v uint32
254 expected []byte
255 }{
256 {
257 name: "zero",
258 fieldNum: 1,
259 v: 0,
260 expected: []byte{0x8, 0x0},
261 },
262 {
263 name: "max uint",
264 fieldNum: 2,
265 v: math.MaxUint32,
266 expected: []byte{0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F},
267 },
268 {
269 name: "regular value",
270 fieldNum: 3,
271 v: 42,
272 expected: []byte{0x18, 0x2A},
273 },
274 }
275 for _, tc := range cases {
276 t.Run(tc.name, func(t *testing.T) {
277 dest := make([]byte, len(tc.expected))
278 csproto.NewEncoder(dest).EncodeUInt32(tc.fieldNum, tc.v)
279 assert.Equal(t, tc.expected, dest)
280 })
281 }
282}
283
284func TestEncodePackedUInt32(t *testing.T) {
285 dest := make([]byte, 9)

Callers

nothing calls this directly

Calls 2

NewEncoderFunction · 0.92
EncodeUInt32Method · 0.80

Tested by

no test coverage detected