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

Function TestEncodeUInt64

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

Source from the content-addressed store, hash-verified

302}
303
304func TestEncodeUInt64(t *testing.T) {
305 cases := []struct {
306 name string
307 fieldNum int
308 v uint64
309 expected []byte
310 }{
311 {
312 name: "zero",
313 fieldNum: 1,
314 v: 0,
315 expected: []byte{0x8, 0x0},
316 },
317 {
318 name: "max uint",
319 fieldNum: 2,
320 v: math.MaxUint64,
321 expected: []byte{0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1},
322 },
323 {
324 name: "regular value",
325 fieldNum: 3,
326 v: 421138,
327 expected: []byte{0x18, 0x92, 0xDA, 0x19},
328 },
329 }
330 for _, tc := range cases {
331 t.Run(tc.name, func(t *testing.T) {
332 dest := make([]byte, len(tc.expected))
333 csproto.NewEncoder(dest).EncodeUInt64(tc.fieldNum, tc.v)
334 assert.Equal(t, tc.expected, dest)
335 })
336 }
337}
338
339func TestEncodePackedUInt64(t *testing.T) {
340 dest := make([]byte, 16)

Callers

nothing calls this directly

Calls 2

NewEncoderFunction · 0.92
EncodeUInt64Method · 0.80

Tested by

no test coverage detected