-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcp_ack_test.go
55 lines (47 loc) · 876 Bytes
/
cp_ack_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
54
55
package sms_test
import (
"testing"
"github.com/fkgi/sms"
)
func TestConvertCPAckMO(t *testing.T) {
for i := 0; i < 1000; i++ {
orig := sms.CpAck{
TI: randTransactionID()}
t.Logf("%s", orig)
b := orig.MarshalCP()
t.Logf("% x", b)
res, e := sms.UnmarshalCPMO(b)
if e != nil {
t.Fatal(e)
}
ocom, ok := res.(sms.CpAck)
if !ok {
t.Fatal("mti mismatch")
}
t.Logf("%s", ocom)
if orig.TI != ocom.TI {
t.Fatal("TI mismatch")
}
}
}
func TestConvertCPAckMT(t *testing.T) {
for i := 0; i < 1000; i++ {
orig := sms.CpAck{
TI: randTransactionID()}
t.Logf("%s", orig)
b := orig.MarshalCP()
t.Logf("% x", b)
res, e := sms.UnmarshalCPMT(b)
if e != nil {
t.Fatal(e)
}
ocom, ok := res.(sms.CpAck)
if !ok {
t.Fatal("mti mismatch")
}
t.Logf("%s", ocom)
if orig.TI != ocom.TI {
t.Fatal("TI mismatch")
}
}
}