smalltalk
/
osmo-st-gsm
Archived
1
0
Fork 0

Add a routine to just expand from 7bit packing to unpacked

Modernize the tests. Use #[] if we want a ByteArray and use
>>#asert:equals: to see what is going on.
This commit is contained in:
Holger Hans Peter Freyther 2014-07-29 17:13:27 +02:00
parent 77d1ac2eab
commit 9bd9a9e3b6
2 changed files with 13 additions and 2 deletions

View File

@ -69,6 +69,10 @@ can be subclassed to deal with specifics for USSD and other systems.'>
^ self handleBytes: bytes from: bits
]
GSMDecoding class >> expand: aByteArray [
^self convertToBytes: (self convertFromBytes: aByteArray)
]
GSMDecoding class >> handleBytes: bytes from: bits [
^ bytes asString
]

View File

@ -858,9 +858,16 @@ TestCase subclass: GSMEncodingTest [
| wanted res |
wanted := 'Your remaining balance is:1704 min,expiring on:10-07-2010'.
res := #(16rD9 16r77 16r5D 16r0E 16r92 16r97 16rDB 16rE1 16rB4 16r3B 16rED 16r3E 16r83 16rC4 16r61 16r76 16rD8 16r3D 16r2E 16r83 16rD2 16r73 16r5D 16rEC 16r06 16rA3 16r81 16rDA 16r69 16r37 16rAB 16r8C 16r87 16rA7 16rE5 16r69 16rF7 16r19 16rF4 16r76 16rEB 16r62 16rB0 16r16 16rEC 16rD6 16r92 16rC1 16r62 16r30) asByteArray decodeGSM7Bit.
res := #[16rD9 16r77 16r5D 16r0E 16r92 16r97 16rDB 16rE1 16rB4 16r3B 16rED 16r3E 16r83 16rC4 16r61 16r76 16rD8 16r3D 16r2E 16r83 16rD2 16r73 16r5D 16rEC 16r06 16rA3 16r81 16rDA 16r69 16r37 16rAB 16r8C 16r87 16rA7 16rE5 16r69 16rF7 16r19 16rF4 16r76 16rEB 16r62 16rB0 16r16 16rEC 16rD6 16r92 16rC1 16r62 16r30] decodeGSM7Bit.
self assert: res = wanted.
self assert: res equals: wanted.
]
testExpand [
| wanted res |
wanted := 'Your remaining balance is:1704 min,expiring on:10-07-2010' asByteArray.
res := GSMDecoding expand: #[217 119 93 14 146 151 219 225 180 59 237 62 131 196 97 118 216 61 46 131 210 115 93 236 6 163 129 218 105 55 171 140 135 167 229 105 247 25 244 118 235 98 176 22 236 214 146 193 98 48].
self assert: res equals: wanted
]
testUSSDEncode [