improve coverage

This commit is contained in:
aler9
2021-05-12 16:03:15 +02:00
parent 4d1c2d1831
commit 8be64d9cf6
8 changed files with 123 additions and 19 deletions

View File

@@ -222,6 +222,16 @@ func TestRequestReadErrors(t *testing.T) {
[]byte("GET rtsp://testing123 RTSP/1.0\r\nContent-Length: 17\r\n\r\n123"),
"unexpected EOF",
},
{
"invalid content-length",
[]byte("GET rtsp://testing123 RTSP/1.0\r\nContent-Length: aaa\r\n\r\n123"),
"invalid Content-Length",
},
{
"too big content-length",
[]byte("GET rtsp://testing123 RTSP/1.0\r\nContent-Length: 1000000\r\n\r\n123"),
"Content-Length exceeds 131072 (it's 1000000)",
},
} {
t.Run(ca.name, func(t *testing.T) {
var req Request
@@ -245,3 +255,13 @@ func TestRequestReadIgnoreFrames(t *testing.T) {
err := req.ReadIgnoreFrames(rb, buf)
require.NoError(t, err)
}
func TestRequestReadIgnoreFramesError(t *testing.T) {
byts := []byte{0x25}
rb := bufio.NewReader(bytes.NewBuffer(byts))
buf := make([]byte, 10)
var req Request
err := req.ReadIgnoreFrames(rb, buf)
require.Equal(t, "EOF", err.Error())
}