ber: Move the tuple to constructed.. add X690 types I know
This commit is contained in:
parent
ec1e5a94db
commit
b176bea4b5
|
@ -60,6 +60,46 @@ Object subclass: BERTag [
|
|||
yourself
|
||||
]
|
||||
|
||||
BERTag class >> endOfContents [
|
||||
<category: 'x690 types'>
|
||||
^ self fromTuple: #(0 false 0)
|
||||
]
|
||||
|
||||
BERTag class >> boolean [
|
||||
<category: 'x690 types'>
|
||||
^ self fromTuple: #(0 false 1)
|
||||
]
|
||||
|
||||
BERTag class >> integer [
|
||||
<category: 'x690 types'>
|
||||
^ self fromTuple: #(0 false 2)
|
||||
]
|
||||
|
||||
BERTag class >> octetString [
|
||||
<category: 'x690 types'>
|
||||
^ self fromTuple: #(0 false 4)
|
||||
]
|
||||
|
||||
BERTag class >> null [
|
||||
<category: 'x690 types'>
|
||||
^ self fromTuple: #(0 false 5)
|
||||
]
|
||||
|
||||
BERTag class >> enumerated [
|
||||
<category: 'x690 types'>
|
||||
^ self fromTuple: #(0 false 10)
|
||||
]
|
||||
|
||||
BERTag class >> sequence [
|
||||
<category: 'x690 types'>
|
||||
^ self fromTuple: #(0 true 16)
|
||||
]
|
||||
|
||||
BERTag class >> set [
|
||||
<category: 'x690 types'>
|
||||
^ self fromTuple: #(0 true 17)
|
||||
]
|
||||
|
||||
initialize [
|
||||
<category: 'init'>
|
||||
classType := BERTag classUniversal.
|
||||
|
@ -92,7 +132,7 @@ Object subclass: BERTag [
|
|||
<category: 'decoding'>
|
||||
|
||||
classType := aTuple first bitAnd: 16r3.
|
||||
constructed := aTuple second not.
|
||||
constructed := aTuple second.
|
||||
tagValue := aTuple third.
|
||||
]
|
||||
|
||||
|
@ -135,6 +175,6 @@ Object subclass: BERTag [
|
|||
|
||||
asTuple [
|
||||
<category: 'conversion'>
|
||||
^ Array with: self classType with: self isPrimitive with: self tagValue.
|
||||
^ Array with: self classType with: self isConstructed with: self tagValue.
|
||||
]
|
||||
]
|
||||
|
|
|
@ -19,14 +19,14 @@
|
|||
TestCase subclass: BERTagTest [
|
||||
testSimpleTag [
|
||||
<category: 'test'>
|
||||
self assert: (BERTag parseFrom: #(16rA1) asByteArray readStream) asTuple = #(2 false 1).
|
||||
self assert: (BERTag parseFrom: #(16rA1) asByteArray readStream) asTuple = #(2 true 1).
|
||||
]
|
||||
|
||||
testFromTuple [
|
||||
| tuple |
|
||||
<category: 'test'>
|
||||
|
||||
tuple := #(2 false 1).
|
||||
tuple := #(2 true 1).
|
||||
self assert: (BERTag fromTuple: tuple) asTuple = tuple.
|
||||
]
|
||||
|
||||
|
@ -34,7 +34,7 @@ TestCase subclass: BERTagTest [
|
|||
| tuple stream |
|
||||
<category: 'test'>
|
||||
|
||||
tuple := #(2 false 1).
|
||||
tuple := #(2 true 1).
|
||||
stream := WriteStream on: (ByteArray new: 1).
|
||||
(BERTag fromTuple: tuple) writeOn: stream.
|
||||
|
||||
|
|
Reference in New Issue