Juha Hyttinen | ff8dccd | 2019-12-10 14:34:07 +0200 | [diff] [blame^] | 1 | /* |
| 2 | ================================================================================== |
| 3 | Copyright (c) 2019 AT&T Intellectual Property. |
| 4 | Copyright (c) 2019 Nokia |
| 5 | |
| 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 |
| 9 | |
| 10 | http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | |
| 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 | ================================================================================== |
| 18 | */ |
| 19 | |
| 20 | package conv |
| 21 | |
| 22 | import ( |
| 23 | "testing" |
| 24 | ) |
| 25 | |
| 26 | func TestPlmnId1(t *testing.T) { |
| 27 | |
| 28 | var ident PlmnIdentity |
| 29 | ident.StringPut("23350") |
| 30 | |
| 31 | if ident.Val[0] != 0x32 { |
| 32 | t.Errorf("TestPlmnId1: ident.val[0] expected 0x32 got 0x%x", ident.Val[0]) |
| 33 | } |
| 34 | |
| 35 | if ident.Val[1] != 0xf3 { |
| 36 | t.Errorf("TestPlmnId1: ident.val[1] expected 0xf3 got 0x%x", ident.Val[1]) |
| 37 | } |
| 38 | |
| 39 | if ident.Val[2] != 0x05 { |
| 40 | t.Errorf("TestPlmnId1: ident.val[2] expected 0x05 got 0x%x", ident.Val[2]) |
| 41 | } |
| 42 | |
| 43 | fullstr := ident.String() |
| 44 | if fullstr != "23350" { |
| 45 | t.Errorf("TestPlmnId2: fullstr expected 23350 got %s", fullstr) |
| 46 | } |
| 47 | |
| 48 | mccstr := ident.MccString() |
| 49 | if mccstr != "233" { |
| 50 | t.Errorf("TestPlmnId1: mcc expected 233 got %s", mccstr) |
| 51 | } |
| 52 | mncstr := ident.MncString() |
| 53 | if mncstr != "50" { |
| 54 | t.Errorf("TestPlmnId1: mnc expected 50 got %s", mncstr) |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | func TestPlmnId2(t *testing.T) { |
| 59 | |
| 60 | var ident PlmnIdentity |
| 61 | ident.StringPut("233550") |
| 62 | |
| 63 | if ident.Val[0] != 0x32 { |
| 64 | t.Errorf("TestPlmnId1: ident.val[0] expected 0x32 got 0x%x", ident.Val[0]) |
| 65 | } |
| 66 | |
| 67 | if ident.Val[1] != 0x03 { |
| 68 | t.Errorf("TestPlmnId1: ident.val[1] expected 0x03 got 0x%x", ident.Val[1]) |
| 69 | } |
| 70 | |
| 71 | if ident.Val[2] != 0x55 { |
| 72 | t.Errorf("TestPlmnId1: ident.val[2] expected 0x55 got 0x%x", ident.Val[2]) |
| 73 | } |
| 74 | |
| 75 | fullstr := ident.String() |
| 76 | if fullstr != "233550" { |
| 77 | t.Errorf("TestPlmnId2: fullstr expected 233550 got %s", fullstr) |
| 78 | } |
| 79 | |
| 80 | mccstr := ident.MccString() |
| 81 | if mccstr != "233" { |
| 82 | t.Errorf("TestPlmnId2: mcc expected 233 got %s", mccstr) |
| 83 | } |
| 84 | mncstr := ident.MncString() |
| 85 | if mncstr != "550" { |
| 86 | t.Errorf("TestPlmnId2: mnc expected 550 got %s", mncstr) |
| 87 | } |
| 88 | } |