MCPcopy Create free account
hub / github.com/pion/rtp / TestRFC8285OneByteMultipleExtensionsWithPadding

Function TestRFC8285OneByteMultipleExtensionsWithPadding

packet_test.go:204–273  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

202}
203
204func TestRFC8285OneByteMultipleExtensionsWithPadding(t *testing.T) {
205 p := &Packet{}
206
207 // 0 1 2 3
208 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
209 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
210 // | 0xBE | 0xDE | length=3 |
211 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
212 // | ID | L=0 | data | ID | L=1 | data...
213 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
214 // ...data | 0 (pad) | 0 (pad) | ID | L=3 |
215 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
216 // | data |
217 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
218 rawPkt := []byte{
219 0x90, 0xe0, 0x69, 0x8f, 0xd9, 0xc2, 0x93, 0xda, 0x1c, 0x64,
220 0x27, 0x82, 0xBE, 0xDE, 0x00, 0x03, 0x10, 0xAA, 0x21, 0xBB,
221 0xBB, 0x00, 0x00, 0x33, 0xCC, 0xCC, 0xCC, 0xCC,
222 // Payload
223 0x98, 0x36, 0xbe, 0x88, 0x9e,
224 }
225 if err := p.Unmarshal(rawPkt); err != nil {
226 t.Fatal("Unmarshal err for valid extension")
227 }
228
229 ext1 := p.GetExtension(1)
230 ext1Expect := []byte{0xAA}
231 if !bytes.Equal(ext1, ext1Expect) {
232 t.Errorf("Extension has incorrect data. Got: %v+, Expected: %v+", ext1, ext1Expect)
233 }
234
235 ext2 := p.GetExtension(2)
236 ext2Expect := []byte{0xBB, 0xBB}
237 if !bytes.Equal(ext2, ext2Expect) {
238 t.Errorf("Extension has incorrect data. Got: %v+, Expected: %v+", ext2, ext2Expect)
239 }
240
241 ext3 := p.GetExtension(3)
242 ext3Expect := []byte{0xCC, 0xCC, 0xCC, 0xCC}
243 if !bytes.Equal(ext3, ext3Expect) {
244 t.Errorf("Extension has incorrect data. Got: %v+, Expected: %v+", ext3, ext3Expect)
245 }
246
247 rawPktReMarshal := []byte{
248 0x90, 0xe0, 0x69, 0x8f, 0xd9, 0xc2, 0x93, 0xda, 0x1c, 0x64,
249 0x27, 0x82, 0xBE, 0xDE, 0x00, 0x03, 0x10, 0xAA, 0x21, 0xBB,
250 0xBB, 0x33, 0xCC, 0xCC, 0xCC, 0xCC, 0x00, 0x00, // padding is moved to the end by re-marshaling
251 // Payload
252 0x98, 0x36, 0xbe, 0x88, 0x9e,
253 }
254 dstBuf := map[string][]byte{
255 "CleanBuffer": make([]byte, 1000),
256 "DirtyBuffer": make([]byte, 1000),
257 }
258 for i := range dstBuf["DirtyBuffer"] {
259 dstBuf["DirtyBuffer"][i] = 0xFF
260 }
261 for name, buf := range dstBuf {

Callers

nothing calls this directly

Calls 3

UnmarshalMethod · 0.95
MarshalToMethod · 0.95
GetExtensionMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…