X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=e2ap%2Fpkg%2Fconv%2Fplmn_test.go;fp=e2ap%2Fpkg%2Fconv%2Fplmn_test.go;h=20a66177486e68fbbe67ff21b970f608e3af3695;hb=ff8dccd02d76eebfccc0b509ce0b42a2c1760e12;hp=0000000000000000000000000000000000000000;hpb=f1d0eb6a82e11f14f60e3636d526299ced0173ea;p=ric-plt%2Fsubmgr.git diff --git a/e2ap/pkg/conv/plmn_test.go b/e2ap/pkg/conv/plmn_test.go new file mode 100644 index 0000000..20a6617 --- /dev/null +++ b/e2ap/pkg/conv/plmn_test.go @@ -0,0 +1,88 @@ +/* +================================================================================== + Copyright (c) 2019 AT&T Intellectual Property. + Copyright (c) 2019 Nokia + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +================================================================================== +*/ + +package conv + +import ( + "testing" +) + +func TestPlmnId1(t *testing.T) { + + var ident PlmnIdentity + ident.StringPut("23350") + + if ident.Val[0] != 0x32 { + t.Errorf("TestPlmnId1: ident.val[0] expected 0x32 got 0x%x", ident.Val[0]) + } + + if ident.Val[1] != 0xf3 { + t.Errorf("TestPlmnId1: ident.val[1] expected 0xf3 got 0x%x", ident.Val[1]) + } + + if ident.Val[2] != 0x05 { + t.Errorf("TestPlmnId1: ident.val[2] expected 0x05 got 0x%x", ident.Val[2]) + } + + fullstr := ident.String() + if fullstr != "23350" { + t.Errorf("TestPlmnId2: fullstr expected 23350 got %s", fullstr) + } + + mccstr := ident.MccString() + if mccstr != "233" { + t.Errorf("TestPlmnId1: mcc expected 233 got %s", mccstr) + } + mncstr := ident.MncString() + if mncstr != "50" { + t.Errorf("TestPlmnId1: mnc expected 50 got %s", mncstr) + } +} + +func TestPlmnId2(t *testing.T) { + + var ident PlmnIdentity + ident.StringPut("233550") + + if ident.Val[0] != 0x32 { + t.Errorf("TestPlmnId1: ident.val[0] expected 0x32 got 0x%x", ident.Val[0]) + } + + if ident.Val[1] != 0x03 { + t.Errorf("TestPlmnId1: ident.val[1] expected 0x03 got 0x%x", ident.Val[1]) + } + + if ident.Val[2] != 0x55 { + t.Errorf("TestPlmnId1: ident.val[2] expected 0x55 got 0x%x", ident.Val[2]) + } + + fullstr := ident.String() + if fullstr != "233550" { + t.Errorf("TestPlmnId2: fullstr expected 233550 got %s", fullstr) + } + + mccstr := ident.MccString() + if mccstr != "233" { + t.Errorf("TestPlmnId2: mcc expected 233 got %s", mccstr) + } + mncstr := ident.MncString() + if mncstr != "550" { + t.Errorf("TestPlmnId2: mnc expected 550 got %s", mncstr) + } +}