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

Function TestRFC8285TwoByteMultipleExtensionsWithPadding

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

Source from the content-addressed store, hash-verified

367}
368
369func TestRFC8285TwoByteMultipleExtensionsWithPadding(t *testing.T) {
370 p := &Packet{}
371
372 // 0 1 2 3
373 // 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
374 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
375 // | 0x10 | 0x00 | length=3 |
376 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
377 // | ID=1 | L=0 | ID=2 | L=1 |
378 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
379 // | data | 0 (pad) | ID=3 | L=4 |
380 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
381 // | data |
382 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
383 rawPkt := []byte{
384 0x90, 0xe0, 0x69, 0x8f, 0xd9, 0xc2, 0x93, 0xda, 0x1c, 0x64,
385 0x27, 0x82, 0x10, 0x00, 0x00, 0x03, 0x01, 0x00, 0x02, 0x01,
386 0xBB, 0x00, 0x03, 0x04, 0xCC, 0xCC, 0xCC, 0xCC, 0x98, 0x36,
387 0xbe, 0x88, 0x9e,
388 }
389 if err := p.Unmarshal(rawPkt); err != nil {
390 t.Fatal("Unmarshal err for valid extension")
391 }
392
393 ext1 := p.GetExtension(1)
394 ext1Expect := []byte{}
395 if !bytes.Equal(ext1, ext1Expect) {
396 t.Errorf("Extension has incorrect data. Got: %v+, Expected: %v+", ext1, ext1Expect)
397 }
398
399 ext2 := p.GetExtension(2)
400 ext2Expect := []byte{0xBB}
401 if !bytes.Equal(ext2, ext2Expect) {
402 t.Errorf("Extension has incorrect data. Got: %v+, Expected: %v+", ext2, ext2Expect)
403 }
404
405 ext3 := p.GetExtension(3)
406 ext3Expect := []byte{0xCC, 0xCC, 0xCC, 0xCC}
407 if !bytes.Equal(ext3, ext3Expect) {
408 t.Errorf("Extension has incorrect data. Got: %v+, Expected: %v+", ext3, ext3Expect)
409 }
410}
411
412func TestRFC8285TwoByteMultipleExtensionsWithLargeExtension(t *testing.T) {
413 // 0 1 2 3

Callers

nothing calls this directly

Calls 2

UnmarshalMethod · 0.95
GetExtensionMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…