From 9bd9a9e3b6826f99ec330ec0086321a599e470f6 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Tue, 29 Jul 2014 17:13:27 +0200 Subject: [PATCH] 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. --- GSMEncoding.st | 4 ++++ Tests.st | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/GSMEncoding.st b/GSMEncoding.st index 2bcac10..34f2fac 100644 --- a/GSMEncoding.st +++ b/GSMEncoding.st @@ -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 ] diff --git a/Tests.st b/Tests.st index 550f9e2..a14d867 100644 --- a/Tests.st +++ b/Tests.st @@ -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 [