base: improve coverage

This commit is contained in:
aler9
2021-05-11 12:48:03 +02:00
parent fa2830eb22
commit f02db78dec
2 changed files with 97 additions and 1 deletions

View File

@@ -6,11 +6,15 @@ import (
"github.com/stretchr/testify/require"
)
func TestURLInvalid(t *testing.T) {
func TestURLError(t *testing.T) {
for _, ca := range []struct {
name string
enc string
}{
{
"invalid",
"testing",
},
{
"with opaque data",
"rtsp:opaque?query",
@@ -63,6 +67,30 @@ func TestURLRTSPPath(t *testing.T) {
}
}
func TestURLClone(t *testing.T) {
u := MustParseURL("rtsp://localhost:8554/test/stream")
u2 := u.Clone()
u.Host = "otherhost"
require.Equal(t, &URL{
Scheme: "rtsp",
Host: "otherhost",
Path: "/test/stream",
}, u)
require.Equal(t, &URL{
Scheme: "rtsp",
Host: "localhost:8554",
Path: "/test/stream",
}, u2)
}
func TestURLErrorRTSPPath(t *testing.T) {
u := MustParseURL("rtsp://localhost:8554")
_, ok := u.RTSPPath()
require.Equal(t, false, ok)
}
func TestURLRTSPPathAndQuery(t *testing.T) {
for _, ca := range []struct {
u *URL