aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2017-07-07 12:10:45 +0200
committerIlya Etingof <etingof@gmail.com>2017-07-07 12:10:45 +0200
commit4cda2dd3b5323ef6b383e1fa5613a0d38243775c (patch)
tree218174ca1d3647534bbd9fe117361368abc1919d /tests
parentf0dbb71d3da3524baa52176df732eb979c76cc17 (diff)
downloadpyasn1-4cda2dd3b5323ef6b383e1fa5613a0d38243775c.tar.gz
fixed SET, OCTET STRING and BITSTRING DER encoder
Diffstat (limited to 'tests')
-rw-r--r--tests/codec/der/test_encoder.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/tests/codec/der/test_encoder.py b/tests/codec/der/test_encoder.py
index 0611dc8..a148763 100644
--- a/tests/codec/der/test_encoder.py
+++ b/tests/codec/der/test_encoder.py
@@ -47,19 +47,22 @@ class SetWithChoiceEncoderTestCase(unittest.TestCase):
def setUp(self):
c = univ.Choice(componentType=namedtype.NamedTypes(
namedtype.NamedType('name', univ.OctetString()),
- namedtype.NamedType('amount', univ.Integer(0)))
+ namedtype.NamedType('amount', univ.Boolean()))
)
self.s = univ.Set(componentType=namedtype.NamedTypes(
- namedtype.NamedType('place-holder', univ.Null()),
+ namedtype.NamedType('value', univ.Integer(5)),
namedtype.NamedType('status', c))
)
- def testDefMode(self):
- self.s.setComponentByPosition(0, '')
+ def testComponentsOrdering1(self):
self.s.setComponentByName('status')
- self.s.getComponentByName('status').setComponentByPosition(0, 'ann')
- assert encoder.encode(self.s) == ints2octs((49, 7, 4, 3, 97, 110, 110, 5, 0))
+ self.s.getComponentByName('status').setComponentByPosition(0, 'A')
+ assert encoder.encode(self.s) == ints2octs((49, 6, 2, 1, 5, 4, 1, 65))
+ def testComponentsOrdering2(self):
+ self.s.setComponentByName('status')
+ self.s.getComponentByName('status').setComponentByPosition(1, True)
+ assert encoder.encode(self.s) == ints2octs((49, 6, 1, 1, 255, 2, 1, 5))
suite = unittest.TestLoader().loadTestsFromModule(sys.modules[__name__])