aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2013-04-01 15:08:07 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2013-04-01 15:08:07 +0200
commit0dd9a2287cedf93982fb342185f65943ea966da5 (patch)
tree839c47db0b9bb9ffe41bdf322311d8ddf29275c2
parent94498315cbf04f1762c1329abcfb8d6fcc0334bd (diff)
ua: Add a testcase for M2UAMSG>>#findTag:ifAbsent:, fix the code
Make the findTag:ifAbent: work. The tag didn't have the isTag query selector.
-rw-r--r--Tests.st12
-rw-r--r--ua/M2UA.st5
2 files changed, 17 insertions, 0 deletions
diff --git a/Tests.st b/Tests.st
index 093aa44..a5b9e58 100644
--- a/Tests.st
+++ b/Tests.st
@@ -308,6 +308,18 @@ TestCase subclass: M2UAMSGTests [
self assert: msg msgClass = UAConstants clsMAUP.
self assert: msg msgType = UAConstants maupData.
]
+
+ testFindTag [
+ | inp msg tag |
+ inp := #(16r01 16r00 16r03 16r01 16r00 16r00 16r00 16r10 16r00
+ 16r11 16r00 16r08 16rAC 16r10 16r01 16r51) asByteArray.
+ msg := M2UAMSG parseFrom: inp.
+ tag := msg findTag: M2UAConstants tagReserved ifAbsent: [ nil ].
+ self assert: tag isNil.
+
+ tag := msg findTag: M2UAConstants tagAspIdent ifAbsent: [self fail].
+ self deny: tag isNil.
+ ]
]
TestCase subclass: OsmoUDPSocketTest [
diff --git a/ua/M2UA.st b/ua/M2UA.st
index 995070c..3879a83 100644
--- a/ua/M2UA.st
+++ b/ua/M2UA.st
@@ -282,6 +282,11 @@ Object subclass: M2UATag [
aMsg putByteArray: (ByteArray new: 4 - rest).
].
]
+
+ isTag: aNr [
+ <category: 'accessing'>
+ ^ self nr = aNr
+ ]
]
Object subclass: M2UAMSG [