mirror of
https://github.com/aler9/gortsplib
synced 2025-10-04 14:52:46 +08:00
base: improve tests
This commit is contained in:
@@ -168,20 +168,25 @@ func TestRequestReadErrors(t *testing.T) {
|
||||
"EOF",
|
||||
},
|
||||
{
|
||||
"missing url, protocol, eol",
|
||||
"missing url, protocol, r, n",
|
||||
[]byte("GET"),
|
||||
"EOF",
|
||||
},
|
||||
{
|
||||
"missing protocol, eol",
|
||||
"missing protocol, r, n",
|
||||
[]byte("GET rtsp://testing123/test"),
|
||||
"EOF",
|
||||
},
|
||||
{
|
||||
"missing eol",
|
||||
"missing r, n",
|
||||
[]byte("GET rtsp://testing123/test RTSP/1.0"),
|
||||
"EOF",
|
||||
},
|
||||
{
|
||||
"missing n",
|
||||
[]byte("GET rtsp://testing123/test RTSP/1.0\r"),
|
||||
"EOF",
|
||||
},
|
||||
{
|
||||
"empty method",
|
||||
[]byte(" rtsp://testing123 RTSP/1.0\r\n"),
|
||||
@@ -207,6 +212,16 @@ func TestRequestReadErrors(t *testing.T) {
|
||||
[]byte("GET rtsp://testing123 RTSP/2.0\r\n"),
|
||||
"expected 'RTSP/1.0', got 'RTSP/2.0'",
|
||||
},
|
||||
{
|
||||
"invalid header",
|
||||
[]byte("GET rtsp://testing123 RTSP/1.0\r\nTesting: val\r"),
|
||||
"EOF",
|
||||
},
|
||||
{
|
||||
"invalid body",
|
||||
[]byte("GET rtsp://testing123 RTSP/1.0\r\nContent-Length: 17\r\n\r\n123"),
|
||||
"unexpected EOF",
|
||||
},
|
||||
} {
|
||||
t.Run(ca.name, func(t *testing.T) {
|
||||
var req Request
|
||||
|
@@ -169,6 +169,16 @@ func TestResponseReadErrors(t *testing.T) {
|
||||
[]byte("RTSP/1.0 200 \r\n"),
|
||||
"empty status message",
|
||||
},
|
||||
{
|
||||
"invalid header",
|
||||
[]byte("RTSP/1.0 200 OK\r\nTesting: val\r"),
|
||||
"EOF",
|
||||
},
|
||||
{
|
||||
"invalid body",
|
||||
[]byte("RTSP/1.0 200 OK\r\nContent-Length: 17\r\n\r\n123"),
|
||||
"unexpected EOF",
|
||||
},
|
||||
} {
|
||||
t.Run(ca.name, func(t *testing.T) {
|
||||
var res Response
|
||||
|
Reference in New Issue
Block a user