summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorelie <elie>2015-04-26 13:09:20 +0000
committerelie <elie>2015-04-26 13:09:20 +0000
commitdd0989a290c264585c4a042b949fcbf666326b7c (patch)
tree49e093b94b14e8addfcbd4be133090ee8e38883d /test
parent27da95be36046410dbd9138ff893792bb7e02417 (diff)
downloadpyasn1-dd0989a290c264585c4a042b949fcbf666326b7c.tar.gz
tests for character types added
Diffstat (limited to 'test')
-rw-r--r--test/codec/ber/test_decoder.py14
-rw-r--r--test/codec/ber/test_encoder.py14
2 files changed, 26 insertions, 2 deletions
diff --git a/test/codec/ber/test_decoder.py b/test/codec/ber/test_decoder.py
index 92b7aa3..85915d9 100644
--- a/test/codec/ber/test_decoder.py
+++ b/test/codec/ber/test_decoder.py
@@ -1,4 +1,4 @@
-from pyasn1.type import tag, namedtype, univ
+from pyasn1.type import tag, namedtype, univ, char
from pyasn1.codec.ber import decoder, eoo
from pyasn1.compat.octets import ints2octs, str2octs, null
from pyasn1.error import PyAsn1Error
@@ -397,6 +397,18 @@ class RealDecoderTestCase(unittest.TestCase):
else:
assert 0, 'accepted too-short real'
+class UniversalStringDecoderTestCase(unittest.TestCase):
+ def testDecoder(self):
+ assert decoder.decode(ints2octs((28, 12, 0, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99))) == (char.UniversalString(u'abc'), null)
+
+class BMPStringDecoderTestCase(unittest.TestCase):
+ def testDecoder(self):
+ assert decoder.decode(ints2octs((30, 6, 0, 97, 0, 98, 0, 99))) == (char.BMPString(u'abc'), null)
+
+class UTF8StringDecoderTestCase(unittest.TestCase):
+ def testDecoder(self):
+ assert decoder.decode(ints2octs((12, 3, 97, 98, 99))) == (char.UTF8String(u'abc'), null)
+
class SequenceDecoderTestCase(unittest.TestCase):
def setUp(self):
self.s = univ.Sequence(componentType=namedtype.NamedTypes(
diff --git a/test/codec/ber/test_encoder.py b/test/codec/ber/test_encoder.py
index 3bd0509..d1441b1 100644
--- a/test/codec/ber/test_encoder.py
+++ b/test/codec/ber/test_encoder.py
@@ -1,4 +1,4 @@
-from pyasn1.type import tag, namedtype, univ
+from pyasn1.type import tag, namedtype, univ, char
from pyasn1.codec.ber import encoder
from pyasn1.compat.octets import ints2octs
from pyasn1.error import PyAsn1Error
@@ -294,6 +294,18 @@ class RealEncoderTestCase(unittest.TestCase):
def testZero(self):
assert encoder.encode(univ.Real(0)) == ints2octs((9, 0))
+class UniversalStringEncoderTestCase(unittest.TestCase):
+ def testEncoding(self):
+ assert encoder.encode(char.UniversalString(u'abc')) == ints2octs((28, 12, 0, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99)), 'Incorrect encoding'
+
+class BMPStringEncoderTestCase(unittest.TestCase):
+ def testEncoding(self):
+ assert encoder.encode(char.BMPString(u'abc')) == ints2octs((30, 6, 0, 97, 0, 98, 0, 99)), 'Incorrect encoding'
+
+class UTF8StringEncoderTestCase(unittest.TestCase):
+ def testEncoding(self):
+ assert encoder.encode(char.UTF8String(u'abc')) == ints2octs((12, 3, 97, 98, 99)), 'Incorrect encoding'
+
class SequenceEncoderTestCase(unittest.TestCase):
def setUp(self):
self.s = univ.Sequence(componentType=namedtype.NamedTypes(