def testQByteArrayNull(self):
        '''QDataStream <<>> QByteArray - null'''
        self.stream << QByteArray()

        res = QByteArray()

        self.read_stream >> res
        self.assertEqual(res, QByteArray())
        self.assertTrue(res.isEmpty())
        self.assertTrue(res.isNull())
    def testQByteArrayEmpty(self):
        '''QDataStream <<>> QByteArray - empty'''
        self.stream << QByteArray("")

        res = QByteArray()

        self.read_stream >> res
        self.assertEqual(res, QByteArray(""))
        self.assertTrue(res.isEmpty())
        self.assertFalse(res.isNull())
Example #3
0
 def testReader(self):
     ba = QByteArray()
     writer = QCborStreamWriter(ba)
     writer.append(42)
     del writer
     self.assertTrue(not ba.isEmpty())
     reader = QCborStreamReader(ba)
     self.assertTrue(reader.hasNext())
     value = reader.toInteger()
     self.assertEqual(value, 42)
Example #4
0
    def testQByteArrayEmpty(self):
        '''QDataStream <<>> QByteArray - empty'''
        self.stream << QByteArray("")

        res = QByteArray()

        self.read_stream >> res
        self.assertEqual(res, QByteArray(""))
        self.assertTrue(res.isEmpty())
        self.assertFalse(res.isNull())
Example #5
0
    def testQByteArrayNull(self):
        '''QDataStream <<>> QByteArray - null'''
        self.stream << QByteArray()

        res = QByteArray()

        self.read_stream >> res
        self.assertEqual(res, QByteArray())
        self.assertTrue(res.isEmpty())
        self.assertTrue(res.isNull())
Example #6
0
 def testReader(self):
     ba = QByteArray()
     writer = QCborStreamWriter(ba)
     writer.append("hello")
     del writer
     self.assertTrue(not ba.isEmpty())
     reader = QCborStreamReader(ba)
     self.assertTrue(reader.hasNext())
     if (reader.isByteArray()):  # Python 2
         value = reader.readByteArray()
         self.assertTrue(value)
         self.assertEqual(value.data, "hello")
     else:
         self.assertTrue(reader.isString())
         value = reader.readString()
         self.assertTrue(value)
         self.assertEqual(value.data, "hello")