From 38658ec45f4adcbc6f1c27f7f191ffb6f5370c5a Mon Sep 17 00:00:00 2001 From: aler9 <46489434+aler9@users.noreply.github.com> Date: Sun, 4 Jul 2021 12:45:31 +0200 Subject: [PATCH] improve coverage --- pkg/rtpaac/rtpaac_test.go | 9 +++++++++ pkg/rtph264/rtph264_test.go | 20 +++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/pkg/rtpaac/rtpaac_test.go b/pkg/rtpaac/rtpaac_test.go index a38d34ba..7b45d88d 100644 --- a/pkg/rtpaac/rtpaac_test.go +++ b/pkg/rtpaac/rtpaac_test.go @@ -267,6 +267,15 @@ func TestDecodeErrors(t *testing.T) { pkts [][]byte err string }{ + { + "invalid rtp", + [][]byte{ + { + 0xaa, + }, + }, + "RTP header size insufficient: 1 < 4", + }, { "missing payload", [][]byte{ diff --git a/pkg/rtph264/rtph264_test.go b/pkg/rtph264/rtph264_test.go index 4cf2bbd3..cb0b5683 100644 --- a/pkg/rtph264/rtph264_test.go +++ b/pkg/rtph264/rtph264_test.go @@ -287,6 +287,15 @@ func TestDecodeErrors(t *testing.T) { pkts [][]byte err string }{ + { + "invalid rtp", + [][]byte{ + { + 0xaa, + }, + }, + "RTP header size insufficient: 1 < 4", + }, { "missing payload", [][]byte{{ @@ -409,7 +418,7 @@ func TestReadSPSPPS(t *testing.T) { pps []byte }{ { - "standard", + "sps then pps", [][]byte{ {128, 96, 61, 205, 54, 67, 90, 125, 40, 249, 97, 176, 7, 1, 2}, {128, 96, 61, 206, 54, 67, 90, 125, 40, 249, 97, 176, 8, 3, 4}, @@ -417,6 +426,15 @@ func TestReadSPSPPS(t *testing.T) { []byte{0x07, 0x01, 0x02}, []byte{0x08, 0x03, 0x04}, }, + { + "pps then sps", + [][]byte{ + {128, 96, 61, 206, 54, 67, 90, 125, 40, 249, 97, 176, 8, 3, 4}, + {128, 96, 61, 205, 54, 67, 90, 125, 40, 249, 97, 176, 7, 1, 2}, + }, + []byte{0x07, 0x01, 0x02}, + []byte{0x08, 0x03, 0x04}, + }, } { t.Run(ca.name, func(t *testing.T) { i := 0