mirror of https://bitbucket.org/ausocean/av.git
protocol/rtsp: added some commenting to TestReadResponse and required helper function
This commit is contained in:
parent
86bf4cdb90
commit
c552238da5
|
@ -272,6 +272,7 @@ func rmSeqNum(s []string) ([]string, bool) {
|
|||
}
|
||||
|
||||
func TestReadResponse(t *testing.T) {
|
||||
// input has been obtained from a valid RTSP response.
|
||||
input := []byte{
|
||||
0x52, 0x54, 0x53, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x30, 0x20, 0x4f, 0x4b, 0x0d, // |RTSP/1.0 200 OK.|
|
||||
0x0a, 0x43, 0x53, 0x65, 0x71, 0x3a, 0x20, 0x32, 0x0d, 0x0a, 0x44, 0x61, 0x74, 0x65, 0x3a, 0x20, // |.CSeq: 2..Date: |
|
||||
|
@ -284,6 +285,7 @@ func TestReadResponse(t *testing.T) {
|
|||
0x53, 0x45, 0x54, 0x5f, 0x50, 0x41, 0x52, 0x41, 0x4d, 0x45, 0x54, 0x45, 0x52, 0x0d, 0x0a, 0x0d, // |SET_PARAMETER...|
|
||||
0x0a,
|
||||
}
|
||||
|
||||
expect := Response{
|
||||
Proto: "RTSP",
|
||||
ProtoMajor: 1,
|
||||
|
@ -296,6 +298,7 @@ func TestReadResponse(t *testing.T) {
|
|||
"Public": []string{"OPTIONS, DESCRIBE, SETUP, TEARDOWN, PLAY, GET_PARAMETER, SET_PARAMETER"},
|
||||
},
|
||||
}
|
||||
|
||||
got, err := ReadResponse(bytes.NewReader(input))
|
||||
if err != nil {
|
||||
t.Fatalf("should not have got error: %v", err)
|
||||
|
@ -306,6 +309,7 @@ func TestReadResponse(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// respEqual checks the equality of two Responses.
|
||||
func respEqual(got, want Response) bool {
|
||||
for _, f := range [][2]interface{}{
|
||||
{got.Proto, want.Proto},
|
||||
|
@ -327,9 +331,11 @@ func respEqual(got, want Response) bool {
|
|||
if k == "Cseq" {
|
||||
continue
|
||||
}
|
||||
|
||||
if len(v) != len(want.Header[k]) {
|
||||
return false
|
||||
}
|
||||
|
||||
for i, _v := range v {
|
||||
if _v != want.Header[k][i] {
|
||||
return false
|
||||
|
|
Loading…
Reference in New Issue