mirror of
https://github.com/aler9/gortsplib
synced 2025-10-04 23:02:45 +08:00
improve coverage
This commit is contained in:
@@ -288,3 +288,16 @@ func TestRequestReadIgnoreFramesError(t *testing.T) {
|
|||||||
err := req.ReadIgnoreFrames(rb, buf)
|
err := req.ReadIgnoreFrames(rb, buf)
|
||||||
require.Equal(t, "EOF", err.Error())
|
require.Equal(t, "EOF", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRequestString(t *testing.T) {
|
||||||
|
byts := []byte("OPTIONS rtsp://example.com/media.mp4 RTSP/1.0\r\n" +
|
||||||
|
"CSeq: 1\r\n" +
|
||||||
|
"Content-Length: 7\r\n" +
|
||||||
|
"\r\n" +
|
||||||
|
"testing")
|
||||||
|
|
||||||
|
var req Request
|
||||||
|
err := req.Read(bufio.NewReader(bytes.NewBuffer(byts)))
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, string(byts), req.String())
|
||||||
|
}
|
||||||
|
@@ -273,3 +273,16 @@ func TestResponseReadIgnoreFramesError(t *testing.T) {
|
|||||||
err := res.ReadIgnoreFrames(rb, buf)
|
err := res.ReadIgnoreFrames(rb, buf)
|
||||||
require.Equal(t, "EOF", err.Error())
|
require.Equal(t, "EOF", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestResponseString(t *testing.T) {
|
||||||
|
byts := []byte("RTSP/1.0 200 OK\r\n" +
|
||||||
|
"CSeq: 3\r\n" +
|
||||||
|
"Content-Length: 7\r\n" +
|
||||||
|
"\r\n" +
|
||||||
|
"testing")
|
||||||
|
|
||||||
|
var res Response
|
||||||
|
err := res.Read(bufio.NewReader(bytes.NewBuffer(byts)))
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, string(byts), res.String())
|
||||||
|
}
|
||||||
|
@@ -10,23 +10,32 @@ func TestURLError(t *testing.T) {
|
|||||||
for _, ca := range []struct {
|
for _, ca := range []struct {
|
||||||
name string
|
name string
|
||||||
enc string
|
enc string
|
||||||
|
err string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"invalid",
|
"invalid",
|
||||||
"testing",
|
":testing",
|
||||||
|
"parse \":testing\": missing protocol scheme",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"unsupported scheme",
|
||||||
|
"http://testing",
|
||||||
|
"unsupported scheme 'http'",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"with opaque data",
|
"with opaque data",
|
||||||
"rtsp:opaque?query",
|
"rtsp:opaque?query",
|
||||||
|
"URLs with opaque data are not supported",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"with fragment",
|
"with fragment",
|
||||||
"rtsp://localhost:8554/teststream#fragment",
|
"rtsp://localhost:8554/teststream#fragment",
|
||||||
|
"URLs with fragments are not supported",
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
t.Run(ca.name, func(t *testing.T) {
|
t.Run(ca.name, func(t *testing.T) {
|
||||||
_, err := ParseURL(ca.enc)
|
_, err := ParseURL(ca.enc)
|
||||||
require.Error(t, err)
|
require.Equal(t, ca.err, err.Error())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user