smalltalk
/
osmo-st-gsm
Archived
1
0
Fork 0
This repository has been archived on 2022-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
osmo-st-gsm/Tests.st

192 lines
5.3 KiB
Smalltalk
Raw Normal View History

TestCase subclass: GSM0808Test [
testLAI [
| lai res |
res := #(16r72 16rF4 16r80) asByteArray.
lai := LAI generateLAI: 274 mnc: 8.
self assert: lai = res.
]
testCellIE [
| ie res msg |
res := #(5 8 0 114 244 128 32 18 117 48) asByteArray.
msg := Osmo.MessageBuffer new.
ie := GSMCellIdentifier initWith: 274 mnc: 8 lac: 8210 ci: 30000.
ie writeOn: msg.
self assert: msg asByteArray = res.
ie := GSMCellIdentifier parseFrom: res.
self assert: ie mcc = 274.
self assert: ie mnc = 8.
self assert: ie lac = 8210.
self assert: ie ci = 30000.
]
testLayer3IE [
| ie res msg |
res := #(23 3 1 2 3) asByteArray.
msg := Osmo.MessageBuffer new.
ie := GSMLayer3Info initWith: #(1 2 3) asByteArray.
ie writeOn: msg.
self assert: msg asByteArray = res.
ie := GSMLayer3Info parseFrom: res.
self assert: ie data = #(1 2 3) asByteArray.
]
testComplL3 [
| msg buf ie res |
msg := IEMessage initWith: GSM0808Helper msgComplL3.
msg addIe: (GSMCellIdentifier initWith: 274 mnc: 8 lac: 8210 ci: 30000).
msg addIe: (GSMLayer3Info initWith: #(1 2 3) asByteArray).
buf := Osmo.MessageBuffer new.
msg writeOn: buf.
res := #(16r57 16r05 16r08 16r00 16r72 16rF4 16r80 16r20 16r12
16r75 16r30 16r17 16r03 16r01 16r02 16r03) asByteArray.
self assert: buf asByteArray = res
]
testIEDecoding [
| inp res |
inp := #(16r57 16r05 16r08 16r00 16r72 16rF4 16r80 16r20 16r12
16r75 16r30 16r17 16r03 16r01 16r02 16r03) asByteArray.
res := IEMessage decode: inp with: GSM0808IE.
self assert: res type = GSM0808Helper msgComplL3.
self assert: res ies size = 2.
]
]
TestCase subclass: BSSAPTest [
testPrependManagment [
| msg |
msg := Osmo.MessageBuffer new.
msg putByteArray: #(1 2 3) asByteArray.
BSSAPHelper prependManagement: msg.
self assert: msg asByteArray = #(0 3 1 2 3) asByteArray.
]
testManagment [
| man |
man := BSSAPManagement initWith: #(1 2 3) asByteArray.
self assert: man toMessage asByteArray = #(0 3 1 2 3) asByteArray.
]
testParseManagement [
| man |
man := BSSAPMessage decode: #(0 3 1 2 3) asByteArray.
self assert: (man isKindOf: BSSAPManagement).
self assert: man data = #(1 2 3) asByteArray.
]
testPrependDTAP [
| msg |
msg := Osmo.MessageBuffer new.
msg putByteArray: #(1 2 3) asByteArray.
BSSAPHelper prependDTAP: msg dlci: 0.
self assert: msg asByteArray = #(1 0 3 1 2 3) asByteArray.
]
]
TestCase subclass: GSM48Test [
testKeySeqLu [
| gsm msg res |
res := #(16r70) asByteArray.
msg := Osmo.MessageBuffer new.
gsm := GSM48KeySeqLuType createDefault.
gsm writeOnDirect: msg.
self assert: msg asByteArray = res.
]
testLai [
| gsm msg res |
res := #(16r02 16rF2 16r50 16rFF 16rFE) asByteArray.
msg := Osmo.MessageBuffer new.
gsm := GSM48Lai createDefault.
gsm mcc: 202; mnc: 5; lac: 65534.
gsm writeOnDirect: msg.
self assert: msg asByteArray = res.
]
testCM1 [
| gsm msg res |
res := #(16r33) asByteArray.
msg := Osmo.MessageBuffer new.
gsm := GSM48Classmark1 createDefault.
gsm writeOnDirect: msg.
self assert: msg asByteArray = res.
]
testMI [
| gsm msg res |
res := #(8 41 71 128 0 0 0 116 8) asByteArray.
msg := Osmo.MessageBuffer new.
gsm := GSM48MIdentity createDefault.
gsm imsi: '274080000004780'.
gsm writeOnDirect: msg.
self assert: msg asByteArray = res.
]
testLU [
| gsm msg res |
res := #(5 8 112 2 242 80 255 254 51 8 105 102 1 69 0 114 131 136) asByteArray.
msg := Osmo.MessageBuffer new.
gsm := LocationUpdatingRequest new.
(gsm lai) mcc: 202; mnc: 5; lac: 65534.
(gsm mi) imsi: '666105400273888'.
gsm writeOn: msg.
self assert: msg asByteArray = res
]
]
TestCase subclass: TestMessages [
testLU [
| sccp handler |
handler := SCCPHadler new.
sccp := MessageTests createLU: handler.
self assert: sccp = #(1 154 2 0 2 2 4 2 66 254 15 32 0 30 87 5 8 0 114 244 128 16 3 156 64 23 17 5 8 112 0 240 0 0 0 51 7 97 102 102 102 102 102 246 0 ) asByteArray.
]
testMsgParser [
| msg bssap bssmap ies l3 |
msg := MSGParser parse: #(1 154 2 0 2 2 4 2 66 254 15 32 0 30 87
5 8 0 114 244 128 16 3 156 64 23 17 5 8
112 0 240 0 0 0 51 7 97 102 102 102 102
102 246 0 ) asByteArray.
self assert: (msg isKindOf: Osmo.SCCPConnectionRequest).
bssap := msg data.
self assert: (bssap isKindOf: BSSAPManagement).
bssmap := bssap data.
self assert: (bssmap isKindOf: IEMessage).
ies := bssmap ies.
self assert: ies size = 2.
l3 := bssmap findIE: (GSMLayer3Info elementId) ifAbsent: [
self assert: false.
].
]
]