-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathextmap_test.go
53 lines (45 loc) · 1.29 KB
/
extmap_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT
package sdp
import (
"net/url"
"testing"
"github.com/stretchr/testify/assert"
)
func TestExtmap(t *testing.T) {
passingtests := []struct {
parameter string
expected string
}{
{exampleAttrExtmap1, exampleAttrExtmap1Line},
{exampleAttrExtmap2, exampleAttrExtmap2Line},
}
failingtests := []struct {
parameter string
expected string
}{
{failingAttrExtmap1, failingAttrExtmap1Line},
{failingAttrExtmap2, failingAttrExtmap2Line},
}
for i, u := range passingtests {
actual := ExtMap{}
assert.NoError(t, actual.Unmarshal(u.parameter))
assert.Equal(t, u.expected, actual.Marshal(), "%d: %+v", i, u)
}
for _, u := range failingtests {
actual := ExtMap{}
assert.Error(t, actual.Unmarshal(u.parameter))
}
}
func TestTransportCCExtMap(t *testing.T) {
// a=extmap:<value>["/"<direction>] <URI> <extensionattributes>
// a=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
uri, _ := url.Parse("http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01")
e := ExtMap{
Value: 3,
URI: uri,
}
if e.Marshal() == "3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01" {
t.Error("TestTransportCC failed")
}
}