forked from negbie/sipparser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reason_test.go
34 lines (31 loc) · 1.32 KB
/
reason_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
// Copyright 2011, Shelby Ramsey. All rights reserved.
// Copyright 2018, Eugen Biegler. 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 TestReason(t *testing.T) {
sm := &SipMsg{}
s := "Q.850;cause=16;text=\"NORMAL_CLEARING\""
sm.parseReason(s)
if sm.Reason.Proto != "Q.850" {
t.Errorf("[TestReason] Error parsing reason hdr: Q.850;cause=16;text=\"NORMAL_CLEARING\". Proto should be \"Q.850\" but received: " + sm.Reason.Proto)
}
if sm.Reason.Cause != "16" {
t.Errorf("[TestReason] Error parsing reason hdr: Q.850;cause=16;text=\"NORMAL_CLEARING\". Cause should be \"16\" but received: " + sm.Reason.Cause)
}
if sm.Reason.Text != "NORMAL_CLEARING" {
t.Errorf("[TestReason] Error parsing reason hdr: Q.850;cause=16;text=\"NORMAL_CLEARING\". Text should be \"NORMAL_CLEARING\" but received: " + sm.Reason.Text)
}
s = "Q.850;cause=102"
sm.parseReason(s)
if sm.Reason.Proto != "Q.850" {
t.Errorf("[TestReason] Error parsing reason hdr: Q.850;cause=102. Proto should be \"Q.850\" but received: " + sm.Reason.Proto)
}
if sm.Reason.Cause != "102" {
t.Errorf("[TestReason] Error parsing reason hdr: Q.850;cause=102. Cause should be \"102\" but received: " + sm.Reason.Cause)
}
}