예제 #1
0
    def test_deserializing_java_output_2(self):
        try:
            byte_stream = _get_java_output_stream(self.wd)

            # read integers
            self.assertEqual(42, srl.deserialize_vint(byte_stream))
            self.assertEqual(4242, srl.deserialize_vint(byte_stream))
            self.assertEqual(424242, srl.deserialize_vint(byte_stream))
            self.assertEqual(42424242, srl.deserialize_vint(byte_stream))
            self.assertEqual(-42, srl.deserialize_vint(byte_stream))

            # longs
            self.assertEqual(42, srl.deserialize_vint(byte_stream))
            self.assertEqual(424242, srl.deserialize_vint(byte_stream))
            self.assertEqual(4242424242, srl.deserialize_vint(byte_stream))

            # strings
            # first one is plain ASCII
            self.assertEqual(u"hello world", wu.readString(byte_stream))
            # second has accented characters
            self.assertEqual(u"oggi è giovedì", wu.readString(byte_stream))

            # final piece is an encoded Text object
            self.assertEqual(
                u"à Text object", srl.deserialize_text(byte_stream)
            )
        finally:
            pass
예제 #2
0
    def test_deserializing_java_output_2(self):
        try:
            byte_stream = _get_java_output_stream(self.wd)

            # read integers
            self.assertEqual(42, srl.deserialize_vint(byte_stream))
            self.assertEqual(4242, srl.deserialize_vint(byte_stream))
            self.assertEqual(424242, srl.deserialize_vint(byte_stream))
            self.assertEqual(42424242, srl.deserialize_vint(byte_stream))
            self.assertEqual(-42, srl.deserialize_vint(byte_stream))

            # longs
            self.assertEqual(42, srl.deserialize_vint(byte_stream))
            self.assertEqual(424242, srl.deserialize_vint(byte_stream))
            self.assertEqual(4242424242, srl.deserialize_vint(byte_stream))

            # strings
            # first one is plain ASCII
            self.assertEqual(u"hello world", wu.readString(byte_stream))
            # second has accented characters
            self.assertEqual(u"oggi è giovedì", wu.readString(byte_stream))

            # final piece is an encoded Text object
            self.assertEqual(
                u"à Text object", srl.deserialize_text(byte_stream)
            )
        finally:
            pass
예제 #3
0
 def test_serialize_to_string(self):
     numbers = random.sample(xrange(-18999289888, 18999289888), 10000)
     for n in numbers:
         s = srl.serialize_to_string(n)
         stream = StringIO(s)
         x = srl.deserialize_vint(stream)
         self.assertEqual(n, x)
예제 #4
0
 def test_serialize_to_string(self):
     numbers = random.sample(xrange(-18999289888, 18999289888), 10000)
     for n in numbers:
         s = srl.serialize_to_string(n)
         stream = StringIO(s)
         x = srl.deserialize_vint(stream)
         self.assertEqual(n, x)
예제 #5
0
 def test_int(self):
     stream = self.stream
     for i in xrange(-16782, 16782):
         srl.serialize_vint(i, stream)
     stream.seek(0)
     for i in xrange(-16782, 16782):
         x = srl.deserialize_vint(stream)
         self.assertEqual(i, x)
예제 #6
0
 def test_int(self):
     stream = self.stream
     for i in xrange(-16782, 16782):
         srl.serialize_vint(i, stream)
     stream.seek(0)
     for i in xrange(-16782, 16782):
         x = srl.deserialize_vint(stream)
         self.assertEqual(i, x)
예제 #7
0
 def test_int_big(self):
     stream = self.stream
     numbers = random.sample(xrange(-18999289888, 18999289888), 10000)
     for i in numbers:
         srl.serialize_vint(i, stream)
     stream.seek(0)
     for i in numbers:
         x = srl.deserialize_vint(stream)
         self.assertEqual(i, x)
예제 #8
0
 def test_int_big(self):
     stream = self.stream
     numbers = random.sample(xrange(-18999289888, 18999289888), 10000)
     for i in numbers:
         srl.serialize_vint(i, stream)
     stream.seek(0)
     for i in numbers:
         x = srl.deserialize_vint(stream)
         self.assertEqual(i, x)
예제 #9
0
def readVLong(stream):
    return pser.deserialize_vint(stream)
예제 #10
0
def readVLong(stream):
    return pser.deserialize_vint(stream)