1
0
Fork 0

SCCP: Test parsing the address from a byte array

This commit is contained in:
Holger Hans Peter Freyther 2010-11-15 19:36:41 +01:00
parent 528231cfb6
commit 4e4a179a0f
2 changed files with 16 additions and 0 deletions

10
SCCP.st
View File

@ -92,6 +92,16 @@ SCCPMessage subclass: SCCPAddrReference [
^ (oct1 bitOr: oct2) bitOr: oct3
]
SCCPAddrReference class >> fromByteArray: anArray [
"Parse from a ByteArray"
| oct1 oct2 oct3 |
oct1 := (anArray at: 1) bitShift: 0.
oct2 := (anArray at: 2) bitShift: 8.
oct3 := (anArray at: 3) bitShift: 16.
^ (oct1 bitOr: oct2) bitOr: oct3
]
]
SCCPMessage subclass: SCCPConnectionRequest [

View File

@ -33,6 +33,12 @@ TestCase subclass: SCCPTests [
self assert: msg = #(1 191 0 3 2 2 4 2 66 254 15 4 49 50 51 52 0) asByteArray
]
testAddrFromByteArray [
| byte |
byte := #(191 0 3) asByteArray.
self assert: (SCCPAddrReference fromByteArray: byte) = 16r0300BF
]
]
TestCase subclass: IPATests [