MCPcopy Create free account
hub / github.com/pion/rtcp / TestReadStruct

Function TestReadStruct

packet_buffer_test.go:104–118  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

102}
103
104func TestReadStruct(t *testing.T) {
105 type S struct {
106 A uint8
107 B uint16
108 C uint32
109 D uint64
110 }
111 expected := S{0x01, 0x0203, 0x04050607, 0x08090A0B0C0D0E0F}
112 raw := []byte{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}
113 var output S
114 buffer := packetBuffer{bytes: raw}
115 err := buffer.read(&output)
116 assert.NoError(t, err)
117 assert.Equal(t, expected, output)
118}
119
120func TestReadSlice(t *testing.T) {
121 expected := []uint16{0x0102, 0x0304, 0x0506, 0x0708}

Callers

nothing calls this directly

Calls 1

readMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…