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

Function TestEncodePackedSInt32

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

Source from the content-addressed store, hash-verified

404}
405
406func TestEncodePackedSInt32(t *testing.T) {
407 dest := make([]byte, 10)
408 enc := csproto.NewEncoder(dest)
409 enc.EncodePackedSInt32(1, []int32{0, math.MaxInt32, 42, -42})
410
411 expected := []byte{
412 // tag=1, wire type=2
413 0x0a,
414 // total length (8)
415 0x08,
416 // 0,
417 0x00,
418 // math.MaxUint32
419 0xFE, 0xFF, 0xFF, 0xFF, 0x0F,
420 // 42
421 0x54,
422 // -42
423 0x53,
424 }
425 assert.Equal(t, expected, dest)
426}
427
428func TestEncodeSInt64(t *testing.T) {
429 cases := []struct {

Callers

nothing calls this directly

Calls 2

EncodePackedSInt32Method · 0.95
NewEncoderFunction · 0.92

Tested by

no test coverage detected