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

Function TestEncodeBool

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

Source from the content-addressed store, hash-verified

10)
11
12func TestEncodeBool(t *testing.T) {
13 cases := []struct {
14 name string
15 fieldNum int
16 v bool
17 expected []byte
18 }{
19 {
20 name: "true value",
21 fieldNum: 1,
22 v: true,
23 expected: []byte{0x8, 0x1},
24 },
25 {
26 name: "false value",
27 fieldNum: 2,
28 v: false,
29 expected: []byte{0x10, 0x0},
30 },
31 }
32 for _, tc := range cases {
33 t.Run(tc.name, func(t *testing.T) {
34 dest := make([]byte, len(tc.expected))
35 csproto.NewEncoder(dest).EncodeBool(tc.fieldNum, tc.v)
36 assert.Equal(t, tc.expected, dest)
37 })
38 }
39}
40
41func TestEncodePackedBool(t *testing.T) {
42 dest := make([]byte, 5)

Callers

nothing calls this directly

Calls 2

NewEncoderFunction · 0.92
EncodeBoolMethod · 0.80

Tested by

no test coverage detected