forked from free5gc/nas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nas_test.go
46 lines (38 loc) · 989 Bytes
/
nas_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
package nas
import (
"bytes"
"encoding/hex"
"reflect"
"testing"
"github.com/stretchr/testify/assert"
)
var hexString = "7e00560102000021e440b883d63a9f9c56b3703217152eba2010068f241c77748000b2180e54a9760068"
func TestNasGmmMessage(t *testing.T) {
data, _ := hex.DecodeString(hexString)
m := NewMessage()
err := m.GmmMessageDecode(&data)
assert.Nil(t, err)
buff := new(bytes.Buffer)
err = m.GmmMessageEncode(buff)
assert.Nil(t, err)
}
func TestNasGsmMessage(t *testing.T) {
data, _ := hex.DecodeString(hexString)
m := NewMessage()
err := m.GsmMessageDecode(&data)
assert.NotNil(t, err)
buff := new(bytes.Buffer)
err = m.GsmMessageEncode(buff)
assert.NotNil(t, err)
}
func TestPlainNas(t *testing.T) {
data, _ := hex.DecodeString(hexString)
m := NewMessage()
err := m.PlainNasDecode(&data)
assert.Nil(t, err)
buff, err1 := m.PlainNasEncode()
assert.Nil(t, err1)
if !reflect.DeepEqual(data, buff) {
t.Errorf("Expect : 0x%0x\nOutput: 0x%0x", data, buff)
}
}