2 ==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 ==================================================================================
27 //-----------------------------------------------------------------------------
29 //-----------------------------------------------------------------------------
30 func TestPlmnId(t *testing.T) {
31 var ident PlmnIdentity
33 if ident.Mcc != "123" {
34 t.Errorf("TestPlmnId: mcc expect 123 was %s", ident.Mcc)
36 if ident.Mnc != "45" {
37 t.Errorf("TestPlmnId: mnc expect 45 was %s", ident.Mnc)
41 if ident.Mcc != "123" {
42 t.Errorf("TestPlmnId: mcc expect 123 was %s", ident.Mcc)
44 if ident.Mnc != "456" {
45 t.Errorf("TestPlmnId: mnc expect 456 was %s", ident.Mnc)
50 //-----------------------------------------------------------------------------
52 //-----------------------------------------------------------------------------
53 func TestPlmnIdBcd1(t *testing.T) {
55 var encident PlmnIdentityBcd
58 encbuf := new(bytes.Buffer)
59 retlen, err := encident.EncodeTo(encbuf)
62 t.Errorf("TestPlmnIdBcd1: EncodeTo err %s", err.Error())
65 t.Errorf("TestPlmnIdBcd1: EncodeTo expected len 3 got %d", retlen)
68 encdata := encbuf.Bytes()
70 if encdata[0] != 0x23 {
71 t.Errorf("TestPlmnIdBcd1: encident.val[0] expected 0x23 got 0x%x", encdata[0])
74 if encdata[1] != 0x3f {
75 t.Errorf("TestPlmnIdBcd1: encident.val[1] expected 0x3f got 0x%x", encdata[1])
78 if encdata[2] != 0x50 {
79 t.Errorf("TestPlmnIdBcd1: encident.val[2] expected 0x50 got 0x%x", encdata[2])
82 var decident PlmnIdentityBcd
83 decbuf := []byte{0x23, 0x3f, 0x50}
85 reader := bytes.NewReader(decbuf)
86 retlen, err = decident.DecodeFrom(reader)
89 t.Errorf("TestPlmnIdBcd1: DecodeFrom err %s", err.Error())
92 t.Errorf("TestPlmnIdBcd1: DecodeFrom expected len 3 got %d", retlen)
95 if decident.Mcc != "233" {
96 t.Errorf("TestPlmnIdBcd1: mcc expected 233 got %s", decident.Mcc)
98 if decident.Mnc != "50" {
99 t.Errorf("TestPlmnIdBcd1: mnc expected 50 got %s", decident.Mnc)
103 func TestPlmnIdBcd2(t *testing.T) {
105 var encident PlmnIdentityBcd
109 encbuf := new(bytes.Buffer)
110 retlen, err := encident.EncodeTo(encbuf)
113 t.Errorf("TestPlmnIdBcd2: EncodeTo err %s", err.Error())
116 t.Errorf("TestPlmnIdBcd2: EncodeTo expected len 3 got %d", retlen)
119 encdata := encbuf.Bytes()
121 if encdata[0] != 0x23 {
122 t.Errorf("TestPlmnIdBcd2: encident.val[0] expected 0x23 got 0x%x", encdata[0])
125 if encdata[1] != 0x35 {
126 t.Errorf("TestPlmnIdBcd1: encident.val[1] expected 0x35 got 0x%x", encdata[1])
129 if encdata[2] != 0x50 {
130 t.Errorf("TestPlmnIdBcd2: encident.val[2] expected 0x50 got 0x%x", encdata[2])
133 var decident PlmnIdentityBcd
134 decbuf := []byte{0x23, 0x35, 0x50}
136 reader := bytes.NewReader(decbuf)
137 retlen, err = decident.DecodeFrom(reader)
140 t.Errorf("TestPlmnIdBcd2: DecodeFrom err %s", err.Error())
143 t.Errorf("TestPlmnIdBcd2: DecodeFrom expected len 3 got %d", retlen)
146 if decident.Mcc != "233" {
147 t.Errorf("TestPlmnIdBcd2: mcc expected 233 got %s", decident.Mcc)
149 if decident.Mnc != "550" {
150 t.Errorf("TestPlmnIdBcd2: mnc expected 550 got %s", decident.Mnc)
154 //-----------------------------------------------------------------------------
156 //-----------------------------------------------------------------------------
157 func TestPlmnIdTbcd1(t *testing.T) {
159 var encident PlmnIdentityTbcd
162 encbuf := new(bytes.Buffer)
163 retlen, err := encident.EncodeTo(encbuf)
166 t.Errorf("TestPlmnIdTbcd1: EncodeTo err %s", err.Error())
169 t.Errorf("TestPlmnIdTbcd1: EncodeTo expected len 3 got %d", retlen)
172 encdata := encbuf.Bytes()
174 if encdata[0] != 0x32 {
175 t.Errorf("TestPlmnIdTbcd1: encident.val[0] expected 0x32 got 0x%x", encdata[0])
178 if encdata[1] != 0xf3 {
179 t.Errorf("TestPlmnIdTbcd1: encident.val[1] expected 0xf3 got 0x%x", encdata[1])
182 if encdata[2] != 0x05 {
183 t.Errorf("TestPlmnIdTbcd1: encident.val[2] expected 0x05 got 0x%x", encdata[2])
186 var decident PlmnIdentityTbcd
187 decbuf := []byte{0x32, 0xf3, 0x05}
189 reader := bytes.NewReader(decbuf)
190 retlen, err = decident.DecodeFrom(reader)
193 t.Errorf("TestPlmnIdTbcd1: DecodeFrom err %s", err.Error())
196 t.Errorf("TestPlmnIdTbcd1: DecodeFrom expected len 3 got %d", retlen)
199 if decident.Mcc != "233" {
200 t.Errorf("TestPlmnIdTbcd1: mcc expected 233 got %s", decident.Mcc)
202 if decident.Mnc != "50" {
203 t.Errorf("TestPlmnIdTbcd1: mnc expected 50 got %s", decident.Mnc)
207 func TestPlmnIdTbcd2(t *testing.T) {
209 var encident PlmnIdentityTbcd
213 encbuf := new(bytes.Buffer)
214 retlen, err := encident.EncodeTo(encbuf)
217 t.Errorf("TestPlmnIdTbcd2: EncodeTo err %s", err.Error())
220 t.Errorf("TestPlmnIdTbcd2: EncodeTo expected len 3 got %d", retlen)
223 encdata := encbuf.Bytes()
225 if encdata[0] != 0x32 {
226 t.Errorf("TestPlmnIdTbcd2: encident.val[0] expected 0x32 got 0x%x", encdata[0])
229 if encdata[1] != 0x03 {
230 t.Errorf("TestPlmnIdTbcd1: encident.val[1] expected 0x03 got 0x%x", encdata[1])
233 if encdata[2] != 0x55 {
234 t.Errorf("TestPlmnIdTbcd2: encident.val[2] expected 0x55 got 0x%x", encdata[2])
237 var decident PlmnIdentityTbcd
238 decbuf := []byte{0x32, 0x03, 0x55}
240 reader := bytes.NewReader(decbuf)
241 retlen, err = decident.DecodeFrom(reader)
244 t.Errorf("TestPlmnIdTbcd2: DecodeFrom err %s", err.Error())
247 t.Errorf("TestPlmnIdTbcd2: DecodeFrom expected len 3 got %d", retlen)
250 if decident.Mcc != "233" {
251 t.Errorf("TestPlmnIdTbcd2: mcc expected 233 got %s", decident.Mcc)
253 if decident.Mnc != "550" {
254 t.Errorf("TestPlmnIdTbcd2: mnc expected 550 got %s", decident.Mnc)