-
Notifications
You must be signed in to change notification settings - Fork 2
/
to_test.go
42 lines (37 loc) · 892 Bytes
/
to_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
package main
import (
"fmt"
"testing"
)
func TestParseToHeader(t *testing.T) {
to, err := ParseTo("Bob <sip:[email protected]>;tag=8321234356")
if err != nil {
t.Fail()
}
fmt.Println(to)
if tag, _ := to.GetTag(); tag != "8321234356" {
t.Fail()
}
}
func TestParseToHeaderWithAbsoluteURI(t *testing.T) {
to, err := ParseTo("<urn:service:sos>;tag=8321234356")
if err != nil {
t.Fail()
}
fmt.Println(to)
s, err := to.GetAbsoluteURI()
if err != nil || s != "urn:service:sos" {
t.Fail()
}
}
func TestParseToHeaderWithTel(t *testing.T) {
s := "<tel:190;phone-context=ims.mnc010.mcc724.3gppnetwork.org>;tag=LRF_eb0d2505"
to, err := ParseTo(s)
if err != nil {
t.Errorf("Fail to parse header To: %s with error:%v", s, err)
}
if tag, err := to.GetTag(); err != nil || tag != "LRF_eb0d2505" {
t.Errorf("Fail to get the tag from To: %s", s)
}
fmt.Println(to)
}