|
@@ -6,28 +6,37 @@ class TestCCWireEncoding(unittest.TestCase):
|
|
|
|
|
|
def test_to_wire_of_string(self):
|
|
|
wire = ISC.CC.Message.to_wire({ "simple" : "string" })
|
|
|
- self.assertEqual(wire, b'Skan\x06simple!\x06string')
|
|
|
+ self.assertEqual(wire, b'Skan\x06simple(\x06string')
|
|
|
|
|
|
def test_from_wire_of_string(self):
|
|
|
- wire = b'Skan\x06simple!\x06string'
|
|
|
+ wire = b'Skan\x06simple(\x06string'
|
|
|
decoded = ISC.CC.Message.from_wire(wire)
|
|
|
self.assertEqual(decoded["simple"], "string")
|
|
|
|
|
|
+ def test_to_wire_of_binary_string(self):
|
|
|
+ wire = ISC.CC.Message.to_wire({ "simple" : b'\x01\xff\x02\x85' })
|
|
|
+ self.assertEqual(wire, b'Skan\x06simple!\x04\x01\xff\x02\x85')
|
|
|
+
|
|
|
+ def test_from_wire_of_binary_string(self):
|
|
|
+ wire = b'Skan\x06simple!\x04\x01\xff\x02\x85'
|
|
|
+ decoded = ISC.CC.Message.from_wire(wire)
|
|
|
+ self.assertEqual(decoded["simple"], b'\x01\xff\x02\x85')
|
|
|
+
|
|
|
def test_to_wire_of_list(self):
|
|
|
wire = ISC.CC.Message.to_wire({ "simple" : [ "string" ] })
|
|
|
- self.assertEqual(wire, b'Skan\x06simple#\x08!\x06string')
|
|
|
+ self.assertEqual(wire, b'Skan\x06simple#\x08(\x06string')
|
|
|
|
|
|
def test_from_wire_of_list(self):
|
|
|
- wire = b'Skan\x06simple#\x08!\x06string'
|
|
|
+ wire = b'Skan\x06simple#\x08(\x06string'
|
|
|
decoded = ISC.CC.Message.from_wire(wire)
|
|
|
self.assertEqual(decoded["simple"], [ "string" ])
|
|
|
|
|
|
def test_to_wire_of_hash(self):
|
|
|
wire = ISC.CC.Message.to_wire({ "simple" : { "string" : 1 }})
|
|
|
- self.assertEqual(wire, b'Skan\x06simple"\n\x06string!\x011')
|
|
|
+ self.assertEqual(wire, b'Skan\x06simple"\n\x06string(\x011')
|
|
|
|
|
|
def test_from_wire_of_hash(self):
|
|
|
- wire = b'Skan\x06simple"\n\x06string!\x011'
|
|
|
+ wire = b'Skan\x06simple"\n\x06string(\x011'
|
|
|
decoded = ISC.CC.Message.from_wire(wire)
|
|
|
self.assertEqual(decoded["simple"], { "string" : '1' })
|
|
|
|
|
@@ -42,28 +51,28 @@ class TestCCWireEncoding(unittest.TestCase):
|
|
|
|
|
|
def test_to_wire_of_empty_string(self):
|
|
|
wire = ISC.CC.Message.to_wire({ "simple" : "" })
|
|
|
- self.assertEqual(wire, b'Skan\x06simple!\x00')
|
|
|
+ self.assertEqual(wire, b'Skan\x06simple(\x00')
|
|
|
|
|
|
def test_from_wire_of_empty_string(self):
|
|
|
- wire = b'Skan\x06simple!\x00'
|
|
|
+ wire = b'Skan\x06simple(\x00'
|
|
|
decoded = ISC.CC.Message.from_wire(wire)
|
|
|
self.assertEqual(decoded["simple"], "")
|
|
|
|
|
|
def test_to_wire_of_utf8_string(self):
|
|
|
wire = ISC.CC.Message.to_wire({ "simple" : "せんせい" })
|
|
|
- self.assertEqual(wire, b'Skan\x06simple!\x0c\xe3\x81\x9b\xe3\x82\x93\xe3\x81\x9b\xe3\x81\x84')
|
|
|
+ self.assertEqual(wire, b'Skan\x06simple(\x0c\xe3\x81\x9b\xe3\x82\x93\xe3\x81\x9b\xe3\x81\x84')
|
|
|
|
|
|
def test_from_wire_of_utf8_string(self):
|
|
|
- wire = b'Skan\x06simple!\x0c\xe3\x81\x9b\xe3\x82\x93\xe3\x81\x9b\xe3\x81\x84'
|
|
|
+ wire = b'Skan\x06simple(\x0c\xe3\x81\x9b\xe3\x82\x93\xe3\x81\x9b\xe3\x81\x84'
|
|
|
decoded = ISC.CC.Message.from_wire(wire)
|
|
|
self.assertEqual(decoded["simple"], "せんせい")
|
|
|
|
|
|
def test_to_wire_of_utf8_label(self):
|
|
|
wire = ISC.CC.Message.to_wire({ "せんせい" : "string" })
|
|
|
- self.assertEqual(wire, b'Skan\x0c\xe3\x81\x9b\xe3\x82\x93\xe3\x81\x9b\xe3\x81\x84!\x06string')
|
|
|
+ self.assertEqual(wire, b'Skan\x0c\xe3\x81\x9b\xe3\x82\x93\xe3\x81\x9b\xe3\x81\x84(\x06string')
|
|
|
|
|
|
def test_from_wire_of_utf8_label(self):
|
|
|
- wire = b'Skan\x0c\xe3\x81\x9b\xe3\x82\x93\xe3\x81\x9b\xe3\x81\x84!\x06string'
|
|
|
+ wire = b'Skan\x0c\xe3\x81\x9b\xe3\x82\x93\xe3\x81\x9b\xe3\x81\x84(\x06string'
|
|
|
decoded = ISC.CC.Message.from_wire(wire)
|
|
|
self.assertEqual(decoded["せんせい"], "string")
|
|
|
|