-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpassertedid_test.go
40 lines (37 loc) · 1.36 KB
/
passertedid_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
// Copyright 2011, Shelby Ramsey. All rights reserved.
// Use of this code is governed by a BSD license that can be
// found in the LICENSE.txt file.
package sipparser
// Imports from the go standard library
import (
"testing"
)
func TestPAssertedId(t *testing.T) {
s := "\"VoIP Call\"<sip:[email protected]>"
p := &PAssertedId{Val: s}
p.parse()
if p.Error != nil {
t.Errorf("[TestPAssertedId] Error parsing p-asserted-id hdr: \"VoIP Call\"<sip:[email protected]>. Received err: " + p.Error.Error())
}
if p.Name != "VoIP Call" {
t.Errorf("[TestPAssertedId] Error parsing p-assertd-id hdr: \"VoIP Call\"<sip:[email protected]>. Name should be \"VoIP Call\" but received: " + p.Name)
}
if p.URI == nil {
t.Errorf("[TestPAssertedId] Error parsing p-asserted-id hdr: \"VoIP Call\"<sip:[email protected]>. No URI in parsed hdr.")
}
if p.Params != nil {
t.Errorf("[TestPAssertedId] Error parsing p-asserted-id hdr: \"VoIP Call\"<sip:[email protected]>. p.Params should be nil.")
}
s = "bad header"
p = &PAssertedId{Val: s}
p.parse()
if p.Error == nil {
t.Errorf("[TestPAssertedId] Should have received an err when parsing bad hdr: \"bad header\".")
}
s = "<sip:4.71.122.181:5060;user=phone>"
p = &PAssertedId{Val: s}
p.parse()
if p.URI == nil {
t.Errorf("[TestPAssertedId] No URI for parsing p-asserted-id hdr: <sip:4.71.122.181:5060;user=phone>")
}
}