Beispiel #1
0
    def test_object(self):
        x = amf3.DataInput(self.decoder)

        self._test(b'\t\x01\x09spam\x06\x09eggs\x01', {'spam': 'eggs'},
                   x.readObject)
        # check references
        self._test(b'\t\x00', {'spam': 'eggs'}, x.readObject)
Beispiel #2
0
    def test_utf(self):
        x = amf3.DataInput(self.decoder)

        self._test(b'\x00\x0bhello world', u'hello world', x.readUTF)
        self._test(
            b'\x00\r\xe1\xbc\x94\xce\xb4\xcf\x89\xcf\x83\xce\xb1\xce\xbd',
            u'ἔδωσαν', x.readUTF)
Beispiel #3
0
    def test_byte(self):
        x = amf3.DataInput(self.decoder)

        self.buf.append(b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09')

        for y in range(10):
            self.assertEqual(x.readByte(), y)
Beispiel #4
0
    def test_multi_byte(self):
        # TODO nick: test multiple charsets
        x = amf3.DataInput(self.decoder)

        self._test(b'this is a test', 'this is a test', x.readMultiByte, 14,
                   'utf-8')
        self._test(b'\xe1\xbc\x94\xce\xb4\xcf\x89\xcf\x83\xce\xb1\xce\xbd',
                   u'ἔδωσαν', x.readMultiByte, 13, 'utf-8')
Beispiel #5
0
    def test_boolean(self):
        x = amf3.DataInput(self.decoder)

        self.buf.write(b'\x01')
        self.buf.seek(-1, 2)
        self.assertEqual(x.readBoolean(), True)

        self.buf.write(b'\x00')
        self.buf.seek(-1, 2)
        self.assertEqual(x.readBoolean(), False)
Beispiel #6
0
    def test_utf_bytes(self):
        x = amf3.DataInput(self.decoder)

        self._test(b'\xe1\xbc\x94\xce\xb4\xcf\x89\xcf\x83\xce\xb1\xce\xbd',
                   u'ἔδωσαν', x.readUTFBytes, 13)
Beispiel #7
0
    def test_uint(self):
        x = amf3.DataInput(self.decoder)

        self._test(b'\x00\x00\x007', 55, x.readUnsignedInt)
Beispiel #8
0
    def test_short(self):
        x = amf3.DataInput(self.decoder)

        self._test(b'\x007', 55, x.readShort)
        self._test(b'\xff\xc9', -55, x.readShort)
Beispiel #9
0
    def test_int(self):
        x = amf3.DataInput(self.decoder)

        self._test(b'\x00\x00\x00\x00', 0, x.readInt)
        self._test(b'\xff\xff\xcf\xc7', -12345, x.readInt)
        self._test(b'\x00\x00\x00b', 98, x.readInt)
Beispiel #10
0
    def test_float(self):
        x = amf3.DataInput(self.decoder)

        self._test(b'\x00' * 4, 0.0, x.readFloat)
        self._test(b'?\x00\x00\x00', 0.5, x.readFloat)
Beispiel #11
0
    def test_double(self):
        x = amf3.DataInput(self.decoder)

        self._test(b'\x00' * 8, 0.0, x.readDouble)
        self._test(b'@\x93JEm\\\xfa\xad', 1234.5678, x.readDouble)
Beispiel #12
0
    def test_create(self):
        x = amf3.DataInput(self.decoder)

        self.assertEqual(x.decoder, self.decoder)
        self.assertEqual(x.stream, self.buf)
        self.assertEqual(x.stream, self.decoder.stream)